You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 28, 2026. It is now read-only.
After that change, in the example above timedate1 is not picklable because timedate1.tzinfo contains an instance of _FixedOffset which is not picklable itself. pickle.dumps(datetime1) invokes timedate1.tzinfo.__reduce__(). _FixedOffset class doesn't define the __reduce__() method and the implementation from its parent class is used. tzinfo.__reduce__() assumes that the class implements __getinitargs__() method. This is true for datetime.timezone, but not for _FixedOffset. Eventually, pickle.loads(pickled) tries to call _FixedOffset.__init__() without the required offset argument, resulting in a TypeError.
In practice the issue happens when trying to pickle/unpickle any object containing a datetime generated by Deserializer.deserialize_rfc(), e.g. with multiprocessing.
Potential solutions
Implement _FixedOffset.__getinitargs__().
Implement _FixedOffset.__reduce__().
Make _FixedOffset use the default implementation of __reduce__(), instead of one inherited from datetime.tzinfo: __reduce__ = object.__reduce__
Once Python 2.7 compatibility is no longer required, datetime.timezone can be used instead of _FixedOffset.
Repro
Output (msrest 0.6.13)
Output (msrest 0.6.14)
Details
This regression was introduced in #201.
After that change, in the example above
timedate1is not picklable becausetimedate1.tzinfocontains an instance of_FixedOffsetwhich is not picklable itself.pickle.dumps(datetime1)invokestimedate1.tzinfo.__reduce__()._FixedOffsetclass doesn't define the__reduce__()method and the implementation from its parent class is used.tzinfo.__reduce__()assumes that the class implements__getinitargs__()method. This is true fordatetime.timezone, but not for_FixedOffset. Eventually,pickle.loads(pickled)tries to call_FixedOffset.__init__()without the requiredoffsetargument, resulting in aTypeError.In practice the issue happens when trying to pickle/unpickle any object containing a
datetimegenerated byDeserializer.deserialize_rfc(), e.g. withmultiprocessing.Potential solutions
_FixedOffset.__getinitargs__()._FixedOffset.__reduce__()._FixedOffsetuse the default implementation of__reduce__(), instead of one inherited fromdatetime.tzinfo:__reduce__ = object.__reduce__Once Python 2.7 compatibility is no longer required,
datetime.timezonecan be used instead of_FixedOffset.