Skip to content

struct.Struct inheritance with Python 3.12.0 #112358

Closed
@livrrr

Description

@livrrr

Bug report

Bug description:

import struct

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

obj = MyStruct()

When I run this code I receive an error:

Traceback (most recent call last):
  File "/home/user/bug.py", line 7, in <module>
    obj = MyStruct()
          ^^^^^^^^^^
TypeError: Struct() missing required argument 'format' (pos 1)

It is rather strange error, I have passed format parameter to base class constructor, I receive this error with any value of format parameter.
There are no any problems with this code in Python 3.11 and older.

CPython versions tested on:

3.12

Operating systems tested on:

Linux

Linked PRs

Metadata

Metadata

Labels

3.12only security fixes3.13bugs and security fixesextension-modulesC modules in the Modules dirtype-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions