New submission from Gregory P. Smith <g...@krypto.org>:
The changes from https://bugs.python.org/issue29368 are causing a subclass of list trouble: ``` class FieldList(list): ... def extend(...): ... ``` FieldList has its own extend and append methods that implement additional checks. As it is a list subclass, the new `PyList_CheckExact()` from the afformentioned issue's https://github.com/python/cpython/commit/f89fdc29937139b55dd68587759cadb8468d0190 where it used to be a `PyList_Check()` in 3.6 and earlier is causing the unpickling code to call the instance `.extend()` method instead of internally using `PyList_SetSlice()` at the C level. Calling .extend() naturally fails at this point as __setstate__ hasn't yet been called so the FieldList instance is uninitialized. Here's the code in question https://github.com/google/protorpc/blob/master/protorpc/messages.py#L1126 It used it work. 3.7 broke it. What was unpicklable is now not. To work around this logic would be needed in the extend (and append) methods to check if they're being called on an uninitialized instance. That seems unreasonable. _[credit to my colleague Richard L. for the diagnosis]_ ---------- components: Extension Modules, Library (Lib) keywords: 3.7regression messages: 392008 nosy: gregory.p.smith, serhiy.storchaka priority: normal severity: normal stage: needs patch status: open title: unpickling a subclass of list fails when it implements its own extend method type: behavior versions: Python 3.10, Python 3.11, Python 3.7, Python 3.8, Python 3.9 _______________________________________ 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