Description of problem: The tz.tzstr() class fails on some timezone strings, including 'EST5EDT' which is straight from the documentation at https://dateutil.readthedocs.org/en/latest/examples.html#tzstr-examples https://bugs.launchpad.net/dateutil/+bug/1331576 is the upstream bug for this. Found while trying to address https://bugzilla.redhat.com/show_bug.cgi?id=1183382 One of our unittests uses: mock_tz.return_value = tzstr('EST5EDT') which fails with: Traceback (most recent call last): File "/usr/lib/python2.7/site-packages/freezegun/api.py", line 244, in wrapper result = func(*args, **kwargs) File "/usr/lib/python2.7/site-packages/mock.py", line 1201, in patched return func(*args, **keywargs) File "/home/adrian/src/subscription-manager/test/test_format_time.py", line 30, in test_system_dst mock_tz.return_value = tzstr('EST5EDT') File "/usr/lib/python2.7/site-packages/dateutil/tz.py", line 595, in __init__ res = parser._parsetz(s) File "/usr/lib/python2.7/site-packages/dateutil/parser.py", line 923, in _parsetz return DEFAULTTZPARSER.parse(tzstr) File "/usr/lib/python2.7/site-packages/dateutil/parser.py", line 767, in parse l = _timelex.split(tzstr) File "/usr/lib/python2.7/site-packages/dateutil/parser.py", line 139, in split return list(cls(s)) File "/usr/lib/python2.7/site-packages/dateutil/parser.py", line 136, in next return self.__next__() # Python 2.x support File "/usr/lib/python2.7/site-packages/dateutil/parser.py", line 130, in __next__ token = self.get_token() File "/usr/lib/python2.7/site-packages/dateutil/parser.py", line 61, in get_token nextchar = self.instream.read(1) AttributeError: 'str' object has no attribute 'read' Version-Release number of selected component (if applicable): python-dateutil-2.4.0-2.fc22.noarch.rpm How reproducible: Steps to Reproduce: $ python import dateutil.tz dateutil.tz.tzstr('EST5EDT') throws AttributeError Additional info: We don't use tzstr() in in the installed code, only unittests, so we could work around it, but it seems likely to impact other code.
Looks like this only fails if a non-unicode string is used as the tzstr arg. dateutil.tz.tzstr('EST5EDT') FAILS dateutil.tz.tzstr(u'EST5EDT') PASSES dateutil.parser._timelex.__init__:35 seems to do it. def __init__(self, instream): if isinstance(instream, text_type): instream = StringIO(instream) self.instream = instream The isinstance() check fails for a non unicode string. >>> import six >>> a = 'EST' >>> isinstance(a, six.text_type) False >>> a = u'EST' >>> isinstance(a, six.text_type) True So likely only fails on python2 with non unicode strings passed to tzstr()
python-dateutil-2.4.0-3.fc22 has been submitted as an update for Fedora 22. https://admin.fedoraproject.org/updates/python-dateutil-2.4.0-3.fc22
Package python-dateutil-2.4.0-3.fc22: * should fix your issue, * was pushed to the Fedora 22 testing repository, * should be available at your local mirror within two days. Update it with: # su -c 'yum update --enablerepo=updates-testing python-dateutil-2.4.0-3.fc22' as soon as you are able to. Please go to the following url: https://admin.fedoraproject.org/updates/FEDORA-2015-3147/python-dateutil-2.4.0-3.fc22 then log in and leave karma (feedback).
python-dateutil-2.4.0-3.fc22 has been pushed to the Fedora 22 stable repository. If problems still persist, please make note of it in this bug report.