Call to tzname() crashes when timezone name is None
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
dateutil |
New
|
Undecided
|
Unassigned |
Bug Description
Calling tzname() on a datetime object (in my case, the return value of dateutil.
Storing the result of the call to myfunc and then checking if it's None before calling encode() appears to fix the problem. If it is None, then we can just return None, otherwise we can return result.encode() (more or less) safely.
I've personally changed my tz.py as follows because it's been preventing me from using a script I rely on:
- return myfunc(*args, **kwargs).encode()
+ result = myfunc(*args, **kwargs)
+ if not result:
+ return result
+ return result.encode()
having the same problem with debian 8, where a new dateutil has become the default. monkey-patched around it for now, so it's not needed to modify tz.py:
+import dateutil.tz comp(dt) .tzname tz._tzicalvtz. tzname = tzname
+def tzname(self, dt):
+ return self._find_
+dateutil.
(effectively disabling the python3-compat decorator)