pytz.timezone doesn't accept unicode timezone

Bug #718673 reported by Frank Ploss
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
pytz
Fix Released
High
Stuart Bishop

Bug Description

When giving a unicode timezone to pytz.timezone(), it throws an exception.

>>> pytz.timezone(u'US/Central')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.6/dist-packages/pytz-2011b-py2.6.egg/pytz/__init__.py", line 154, in timezone
    _tzinfo_cache[zone] = build_tzinfo(zone, open_resource(zone))
  File "/usr/local/lib/python2.6/dist-packages/pytz-2011b-py2.6.egg/pytz/tzfile.py", line 121, in build_tzinfo
    _transition_info=transition_info))
TypeError: type() argument 1 must be string, not unicode

It certainly is easy to circumvent this, but it is annoying having to remember this special constraint as I am using unicode strings throughout the whole program.

Related branches

Stuart Bishop (stub)
Changed in pytz:
importance: Undecided → High
Revision history for this message
Stuart Bishop (stub) wrote :

This is a regression. Line 146 of pytz/__init__.py used to convert the timezone to ASCII, but this was changed to just confirm the timezone contained just ASCII characters. This was done because the older construct resulted in a bytestring under Python 3.x.

Changed in pytz:
status: New → Triaged
Stuart Bishop (stub)
Changed in pytz:
assignee: nobody → Stuart Bishop (stub)
status: Triaged → Fix Committed
Stuart Bishop (stub)
Changed in pytz:
status: Fix Committed → Fix Released
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.