Thanks to visit codestin.com
Credit goes to github.com

Skip to content

No exception set but raise SystemError when setting _fields_ of ctypes.Structure in __init_subclass__ #99275

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
nyaoouo opened this issue Nov 9, 2022 · 2 comments
Labels
topic-ctypes type-bug An unexpected behavior, bug, or error

Comments

@nyaoouo
Copy link

nyaoouo commented Nov 9, 2022

Bug report

No exception set but raise SystemError when setting _fields_ of ctypes.Structure in __init_subclass__
Reproduce code:

import ctypes


class ParentStructure(ctypes.Structure):
    def __init_subclass__(cls, **kwargs):
        cls._fields_ =[('v1',ctypes.c_uint),('v2',ctypes.c_uint),]
        super().__init_subclass__(**kwargs)


class ChildStructure(ParentStructure):
    pass

Output Exception

Traceback (most recent call last):
  File "D:\Projects\pythonProject\main.py", line 10, in <module>
    class ChildStructure(ParentStructure):
  File "D:\Projects\pythonProject\main.py", line 6, in __init_subclass__
    cls._fields_ =[('v1',ctypes.c_uint),('v2',ctypes.c_uint),]
SystemError: error return without exception set

Your environment

Python 3.10.6 (tags/v3.10.6:9c7b4bd, Aug 1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)] on win32

@nyaoouo nyaoouo added the type-bug An unexpected behavior, bug, or error label Nov 9, 2022
sobolevn added a commit to sobolevn/cpython that referenced this issue Nov 9, 2022
@sobolevn
Copy link
Member

sobolevn commented Nov 9, 2022

I proposed a PR that sets the exception.

sobolevn added a commit to sobolevn/cpython that referenced this issue Nov 9, 2022
sobolevn added a commit to sobolevn/cpython that referenced this issue Nov 9, 2022
sobolevn added a commit to sobolevn/cpython that referenced this issue Nov 9, 2022
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Nov 13, 2022
…_` (pythonGH-99283)

(cherry picked from commit 343eb0f)

Co-authored-by: Nikita Sobolev <[email protected]>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Nov 13, 2022
…_` (pythonGH-99283)

(cherry picked from commit 343eb0f)

Co-authored-by: Nikita Sobolev <[email protected]>
miss-islington added a commit that referenced this issue Nov 13, 2022
…-99283)

(cherry picked from commit 343eb0f)

Co-authored-by: Nikita Sobolev <[email protected]>
miss-islington added a commit that referenced this issue Nov 13, 2022
…-99283)

(cherry picked from commit 343eb0f)

Co-authored-by: Nikita Sobolev <[email protected]>
@encukou
Copy link
Member

encukou commented Sep 18, 2024

Thanks for the fix! I'll close the issue.

@encukou encukou closed this as completed Sep 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic-ctypes type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants