◐ Shell
clean mode source ↗

gh-143715: Deprecate incomplete initialization of struct.Struct() by serhiy-storchaka · Pull Request #145580 · python/cpython

and others added 29 commits

January 10, 2026 16:37
* ``Struct.__new__()`` will require a mandatory argument (format)
* Calls of ``__init__()`` method on initialized Struct are deprecated
This make format argument in the __init__() - optional.  If it's
missing, the object must be already initialized in __new__().
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This catch current pattern for Struct's subclassing like

class MyStruct(Struct):
    def __init__(self):
        super().__init__('>h')

skirpichev

skirpichev

serhiy-storchaka

vstinner

Co-authored-by: Petr Viktorin <encukou@gmail.com>

ljfp pushed a commit to ljfp/cpython that referenced this pull request

Apr 25, 2026
…() (pythonGH-145580)

* Struct.__new__() will require a mandatory argument (format)
* Calls of __init__() method with a different format argument on initialized
  Struct are deprecated

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>