UnknownTimeZoneError: 'Europe/Kyiv' in python3-tz

Bug #1995864 reported by Valentyna
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
python-tz (Ubuntu)
Fix Released
High
Benjamin Drung
Focal
Fix Released
Undecided
Unassigned
Jammy
Fix Released
Undecided
Unassigned

Bug Description

[ Impact ]

I install latest updates on my Ubuntu 20.04 and 22.04 and timezone has changed from Europe/Kiev to Europe/Kyiv, which caused error in my service:
pytz.exceptions.UnknownTimeZoneError: 'Europe/Kyiv'

The problem exists on:
Ubuntu 20.04 python3-tz version - 2019.3-1
Ubuntu 22.04 with version of python3-tz - 2022.1-1.
The problem is solved for kinetic release. Could you please add 'Europe/Kyiv' timezone for previous releases.

[ Test plan ]

Execute following script:

```
#!/usr/bin/python3
from pytz import timezone
print(timezone('Europe/Kyiv'))
```

[ Where problems could occur ]

The list of timezones are brought up-to-date with the latest tzdata version, but this can cause failures with outdated tzdata package versions.

Valentyna (valia0906)
tags: added: focal impish jammy
description: updated
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in python-tz (Ubuntu):
status: New → Confirmed
Revision history for this message
Sebastien Bacher (seb128) wrote :

Thanks, it seems that python-tz needs to be updated for the newer tzdata versions which includes that change

> - Convert Europe/Kiev into Europe/Kyiv

tags: added: regression-update
Revision history for this message
Robie Basak (racb) wrote :

Looks like this was "fixed" upstream by updating the embedded database by pulling in IANA 2022b at https://git.launchpad.net/pytz/commit/?id=fbe098e6d2f78765821c2688fd00db8dab40bbef

So I'm guessing this is failing for users who now have Europe/Kyiv set, and pytz/python-tz/python3-tz cannot find it?

The update in tzdata was to link the old name Europe/Kiev, so I think that should be a workaround for now?

We can certainly try to cherry-pick the Kiev->Kyiv rename. But separately I wonder if this needs fixing "properly" by avoiding the use of embedded code like this, or if that wouldn't be practical for some reason.

Revision history for this message
Robie Basak (racb) wrote :

(and further, if python-tz isn't being updated at the same time as distribution tzinfo updates, then it's going to break in other ways as timezone updates occur)

Revision history for this message
Robie Basak (racb) wrote :

Bug 207604 is relevant.

Revision history for this message
Benjamin Drung (bdrung) wrote :

Thank you for taking the time to report this bug and helping to make Ubuntu better. Can you provide a small test script to demonstrate the regression?

Revision history for this message
James Henstridge (jamesh) wrote :

Long term, it is probably best to move off of pytz. If you're okay to require Python >= 3.9 (released October 2020), then just use the built-in zoneinfo package.

    import pytz => import zoneinfo
    pytz.timezone("foo") => zoneinfo.ZoneInfo("foo")
    pytz.all_timezones => zoneinfo.available_timezones()

There are a few differences in how the two libraries treat repeated dates at daylight saving transitions: pytz tried to solve the problem back when there was ambiguity in the datetime module. The zoneinfo module was designed after they fixed the ambiguity and works a little differently. Chances are things will just work though.

The zoneinfo package does not rely on a hard coded list of time zones, so does not require updates when tzdata changes.

Revision history for this message
Stuart Bishop (stub) wrote :

pytz needs to be updated to 2022.2.1 or later, preferably 2022.6, in supported Ubuntu releases. The ugly alternative is hacking pytz/__init__.py to update the hardcoded list of timezone names to match current reality. pytz code has been almost completely frozen for a decade and new versions will drop in just fine, packaging quirks and Python environment willing.

Yes, it is best to switch from pytz to the support now built into Python 3.9 and later. https://pypi.org/project/pytz-deprecation-shim/ can make this easy in many cases.

Revision history for this message
Stuart Bishop (stub) wrote :

The following script will demonstrate the failure. Europe/Kyiv became a valid timezone name with tzdata 2022b, but the old versions of pytz don't know that:

#!/usr/bin/python
import pytz
pytz.timezone('Europe/Kyiv')

Revision history for this message
Benjamin Drung (bdrung) wrote :

Underlying problem: bug #1996504

description: updated
Revision history for this message
Benjamin Drung (bdrung) wrote :
Revision history for this message
Benjamin Drung (bdrung) wrote :
Benjamin Drung (bdrung)
tags: added: foundations-todo
Changed in python-tz (Ubuntu):
importance: Undecided → High
assignee: nobody → Benjamin Drung (bdrung)
Benjamin Drung (bdrung)
description: updated
Benjamin Drung (bdrung)
Changed in python-tz (Ubuntu):
status: Confirmed → Fix Released
Revision history for this message
Chris Halse Rogers (raof) wrote : Please test proposed package

Hello Valentyna, or anyone else affected,

Accepted python-tz into jammy-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/python-tz/2022.1-1ubuntu0.22.04.0 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, what testing has been performed on the package and change the tag from verification-needed-jammy to verification-done-jammy. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-jammy. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance for helping!

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

Changed in python-tz (Ubuntu Jammy):
status: New → Fix Committed
tags: added: verification-needed verification-needed-jammy
Revision history for this message
Chris Halse Rogers (raof) wrote :

Hello Valentyna, or anyone else affected,

Accepted python-tz into focal-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/python-tz/2019.3-1ubuntu0.20.04.0 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, what testing has been performed on the package and change the tag from verification-needed-focal to verification-done-focal. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-focal. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance for helping!

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

Changed in python-tz (Ubuntu Focal):
status: New → Fix Committed
tags: added: verification-needed-focal
Valentyna (valia0906)
tags: added: verification-done-focal verification-done-jammy
Revision history for this message
Benjamin Drung (bdrung) wrote :

Also verified python3-tz 2022.1-1ubuntu0.22.04.0 in a jammy chroot and python3-tz 2019.3-1ubuntu0.20.04.0 in a focal chroot.

tags: added: verification-done
removed: verification-needed verification-needed-focal verification-needed-jammy
Revision history for this message
Ubuntu SRU Bot (ubuntu-sru-bot) wrote : Autopkgtest regression report (python-tz/2022.1-1ubuntu0.22.04.0)

All autopkgtests for the newly accepted python-tz (2022.1-1ubuntu0.22.04.0) for jammy have finished running.
The following regressions have been reported in tests triggered by the package:

pandas/1.3.5+dfsg-3 (amd64)

Please visit the excuses page listed below and investigate the failures, proceeding afterwards as per the StableReleaseUpdates policy regarding autopkgtest regressions [1].

https://people.canonical.com/~ubuntu-archive/proposed-migration/jammy/update_excuses.html#python-tz

[1] https://wiki.ubuntu.com/StableReleaseUpdates#Autopkgtest_Regressions

Thank you!

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package python-tz - 2022.1-1ubuntu0.22.04.0

---------------
python-tz (2022.1-1ubuntu0.22.04.0) jammy; urgency=medium

  * test: Revert inclusion of PACKRATDATA=backzone
  * Update timezones to tzdata 2022f (LP: #1995864)

 -- Benjamin Drung <email address hidden> Wed, 16 Nov 2022 15:19:43 +0100

Changed in python-tz (Ubuntu Jammy):
status: Fix Committed → Fix Released
Revision history for this message
Brian Murray (brian-murray) wrote : Update Released

The verification of the Stable Release Update for python-tz has completed successfully and the package is now being released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regressions.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package python-tz - 2019.3-1ubuntu0.20.04.0

---------------
python-tz (2019.3-1ubuntu0.20.04.0) focal; urgency=medium

  * test: Revert inclusion of PACKRATDATA=backzone
  * Update timezones to tzdata 2022f (LP: #1995864)

 -- Benjamin Drung <email address hidden> Wed, 16 Nov 2022 15:54:36 +0100

Changed in python-tz (Ubuntu Focal):
status: Fix Committed → Fix Released
Benjamin Drung (bdrung)
tags: removed: foundations-todo
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.