Richard Levasseur <richard...@gmail.com> added the comment:

Here's a self-contained repro:


```
import pickle

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

  def __getstate__(self):
    return self.required

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

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

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

print(mylist)

```

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.

----------
nosy: +richardlev

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue43946>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to