This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author richardlev
Recipients gregory.p.smith, richardlev, serhiy.storchaka
Date 2021-04-27.04:00:15
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Here's a self-contained repro:

import pickle

class MyList(list):
  def __init__(self, required, values):
    self.required = required

  def __getstate__(self):
    return self.required

  def __setstate__(self, state):
    self.required = state

  def extend(self, values):
    assert self.required

mylist = MyList('foo', [1, 2])
pickled = pickle.dumps(mylist)
unpickled = pickle.loads(pickled)



The above will raise an AttributeError when self.required is accessed in extend(). 

Oddly, defining a `__reduce__()` function that simply calls and returns `super().__reduce__()` seems to restore the previous behavior and things work again.
Date User Action Args
2021-04-27 04:00:15richardlevsetrecipients: + richardlev, gregory.p.smith, serhiy.storchaka
2021-04-27 04:00:15richardlevsetmessageid: <>
2021-04-27 04:00:15richardlevlinkissue43946 messages
2021-04-27 04:00:15richardlevcreate