Skip to content
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

ctypes: improve bytes handling #9029

Merged
merged 3 commits into from
Oct 31, 2022
Merged

ctypes: improve bytes handling #9029

merged 3 commits into from
Oct 31, 2022

Conversation

JelleZijlstra
Copy link
Member

No description provided.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@@ -194,7 +194,7 @@ class _SimpleCData(Generic[_T], _CData):
class c_byte(_SimpleCData[int]): ...

class c_char(_SimpleCData[bytes]):
def __init__(self, value: int | bytes = ...) -> None: ...
def __init__(self, value: int | bytes | bytearray = ...) -> None: ...
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I failed to trace through the code for this, but I trust this is correct.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't find the code either but tried it in the REPL. This one allows bytearray but c_char_p doesn't.

@@ -367,6 +367,8 @@ _ctypes.sizeof
# Allowlist entries that cannot or should not be fixed
# ==========

ctypes.Array.raw # exists but stubtest can't see it
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Maybe copy the comment from the stub?

@github-actions
Copy link
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@srittau srittau merged commit 3d8d744 into python:master Oct 31, 2022
@JelleZijlstra JelleZijlstra deleted the ctypes branch October 31, 2022 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants