#1019744 khal: Can't create an event without specifying the timezone

#1019744#5
Date:
2022-09-14 14:19:10 UTC
From:
To:
Dear Maintainer,

Here's what happens when I try to create an event without specifying the TZ :

```
$ khal new -a private_calendar_local '2022-09-15 12:00' "test" :: "test"
/usr/lib/python3/dist-packages/khal/icalendar.py:104: PytzUsageWarning: The localize method is no longer necessary, as this time zone supports the fold attribute (PEP 495). For more details on migrating to a PEP 495-compliant implementation, see https://pytz-deprecation-shim.readthedocs.io/en/latest/migration.html
  dtstart = timezone.localize(dtstart)
/usr/lib/python3/dist-packages/khal/icalendar.py:105: PytzUsageWarning: The localize method is no longer necessary, as this time zone supports the fold attribute (PEP 495). For more details on migrating to a PEP 495-compliant implementation, see https://pytz-deprecation-shim.readthedocs.io/en/latest/migration.html
  dtend = timezone.localize(dtend)
/usr/lib/python3/dist-packages/icalendar/parser.py:54: PytzUsageWarning: The zone attribute is specific to pytz's interface; please migrate to a new time zone provider. For more details on how to do so, see https://pytz-deprecation-shim.readthedocs.io/en/latest/migration.html
  if hasattr(dt.tzinfo, 'zone'):
/usr/lib/python3/dist-packages/icalendar/parser.py:55: PytzUsageWarning: The zone attribute is specific to pytz's interface; please migrate to a new time zone provider. For more details on how to do so, see https://pytz-deprecation-shim.readthedocs.io/en/latest/migration.html
  tzid = dt.tzinfo.zone  # pytz implementation
Traceback (most recent call last):
  File "/usr/bin/khal", line 5, in <module>
    main_khal()
  File "/usr/lib/python3/dist-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3/dist-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3/dist-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3/dist-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/lib/python3/dist-packages/khal/cli.py", line 388, in new
    new_func(
  File "/usr/lib/python3/dist-packages/khal/controllers.py", line 355, in new_from_string
    new_from_args(
  File "/usr/lib/python3/dist-packages/khal/controllers.py", line 381, in new_from_args
    collection.new(event)
  File "/usr/lib/python3/dist-packages/khal/khalendar/khalendar.py", line 208, in new
    event.href, event.etag = self._storages[calendar].upload(event)
  File "/usr/lib/python3/dist-packages/khal/khalendar/vdir.py", line 212, in upload
    if not isinstance(item.raw, str):
  File "/usr/lib/python3/dist-packages/khal/khalendar/event.py", line 382, in raw
    timezone = create_timezone(tzinfo, self.start)
  File "/usr/lib/python3/dist-packages/khal/khalendar/event.py", line 858, in create_timezone
    for one, two in iter(tz._tzinfos.items())
AttributeError: '_PytzShimTimezone' object has no attribute '_tzinfos'
```

Instead I have to do :

```
$ khal new -a private_calendar_local '2022-09-15 12:00 Europe/Paris' "test" :: "test"
```

Please bring the old behavior back, where khal used the system TZ when
no TZ was given.

Regards,

#1019744#10
Date:
2022-09-20 17:31:42 UTC
From:
To:
Dear Maintainer,

while I can easily work around by specifying the timezone when adding events on
the CLI the TUI interface ikhal fails when saving an event:

ikhal
/usr/lib/python3/dist-packages/khal/khalendar/khalendar.py:153:
PytzUsageWarning: The localize method is no longer necessary, as this time zone
supports the fold attribute (PEP 495). For more details on migrating to a PEP
495-compliant implementation, see https://pytz-deprecation-
shim.readthedocs.io/en/latest/migration.html
  localized_events = self.get_localized(localize(start), localize(end))
/usr/lib/python3/dist-packages/khal/khalendar/event.py:541: PytzUsageWarning:
The localize method is no longer necessary, as this time zone supports the fold
attribute (PEP 495). For more details on migrating to a PEP 495-compliant
implementation, see https://pytz-deprecation-
shim.readthedocs.io/en/latest/migration.html
  start_local_datetime = self._locale['local_timezone'].localize(
/usr/lib/python3/dist-packages/khal/khalendar/event.py:543: PytzUsageWarning:
The localize method is no longer necessary, as this time zone supports the fold
attribute (PEP 495). For more details on migrating to a PEP 495-compliant
implementation, see https://pytz-deprecation-
shim.readthedocs.io/en/latest/migration.html
  end_local_datetime = self._locale['local_timezone'].localize(
/usr/lib/python3/dist-packages/khal/khalendar/event.py:546: PytzUsageWarning:
The localize method is no longer necessary, as this time zone supports the fold
attribute (PEP 495). For more details on migrating to a PEP 495-compliant
implementation, see https://pytz-deprecation-
shim.readthedocs.io/en/latest/migration.html
  day_start = self._locale['local_timezone'].localize(
/usr/lib/python3/dist-packages/khal/khalendar/event.py:549: PytzUsageWarning:
The localize method is no longer necessary, as this time zone supports the fold
attribute (PEP 495). For more details on migrating to a PEP 495-compliant
implementation, see https://pytz-deprecation-
shim.readthedocs.io/en/latest/migration.html
  day_end = self._locale['local_timezone'].localize(
/usr/lib/python3/dist-packages/khal/khalendar/khalendar.py:162:
PytzUsageWarning: The localize method is no longer necessary, as this time zone
supports the fold attribute (PEP 495). For more details on migrating to a PEP
495-compliant implementation, see https://pytz-deprecation-
shim.readthedocs.io/en/latest/migration.html
  self._backend.get_localized_calendars(localize(start), localize(end)),
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/khal/ui/__init__.py", line 1358, in
start_pane
    loop.run()
  File "/usr/lib/python3/dist-packages/urwid/main_loop.py", line 287, in run
    self._run()
  File "/usr/lib/python3/dist-packages/urwid/main_loop.py", line 385, in _run
    self.event_loop.run()
  File "/usr/lib/python3/dist-packages/urwid/main_loop.py", line 790, in run
    self._loop()
  File "/usr/lib/python3/dist-packages/urwid/main_loop.py", line 827, in _loop
    self._watch_files[fd]()
  File "/usr/lib/python3/dist-packages/urwid/raw_display.py", line 416, in
<lambda>
    wrapper = lambda: self.parse_input(
  File "/usr/lib/python3/dist-packages/urwid/raw_display.py", line 515, in
parse_input
    callback(processed, processed_codes)
  File "/usr/lib/python3/dist-packages/urwid/main_loop.py", line 412, in
_update
    self.process_input(keys)
  File "/usr/lib/python3/dist-packages/urwid/main_loop.py", line 513, in
process_input
    k = self._topmost_widget.keypress(self.screen_size, k)
  File "/usr/lib/python3/dist-packages/urwid/wimp.py", line 651, in keypress
    return self._current_widget.keypress(size, key)
  File "/usr/lib/python3/dist-packages/urwid/container.py", line 1135, in
keypress
    return self.body.keypress( (maxcol, remaining), key )
  File "/usr/lib/python3/dist-packages/urwid/container.py", line 2316, in
keypress
    key = w.keypress((mc,) + size[1:], key)
  File "/usr/lib/python3/dist-packages/khal/ui/editor.py", line 530, in
keypress
    return super().keypress(size, key)
  File "/usr/lib/python3/dist-packages/khal/ui/widgets.py", line 376, in
keypress
    key = super().keypress(size, key)
  File "/usr/lib/python3/dist-packages/urwid/listbox.py", line 968, in keypress
    key = focus_widget.keypress((maxcol,),key)
  File "/usr/lib/python3/dist-packages/urwid/container.py", line 2316, in
keypress
    key = w.keypress((mc,) + size[1:], key)
  File "/usr/lib/python3/dist-packages/urwid/wimp.py", line 543, in keypress
    self._emit('click')
  File "/usr/lib/python3/dist-packages/urwid/widget.py", line 461, in _emit
    signals.emit_signal(self, name, self, *args)
  File "/usr/lib/python3/dist-packages/urwid/signals.py", line 265, in emit
    result |= self._call_callback(callback, user_arg, user_args, args)
  File "/usr/lib/python3/dist-packages/urwid/signals.py", line 295, in
_call_callback
    return bool(callback(*args_to_pass))
  File "/usr/lib/python3/dist-packages/khal/ui/editor.py", line 510, in save
    self.collection.update(self.event)
  File "/usr/lib/python3/dist-packages/khal/khalendar/khalendar.py", line 172,
in update
    event.etag = self._storages[event.calendar].update(event.href, event,
event.etag)
  File "/usr/lib/python3/dist-packages/khal/khalendar/vdir.py", line 251, in
update
    if not isinstance(item.raw, str):
  File "/usr/lib/python3/dist-packages/khal/khalendar/event.py", line 382, in
raw
    timezone = create_timezone(tzinfo, self.start)
  File "/usr/lib/python3/dist-packages/khal/khalendar/event.py", line 858, in
create_timezone
    for one, two in iter(tz._tzinfos.items())
AttributeError: '_PytzShimTimezone' object has no attribute '_tzinfos'