Skip to content

Fix _ctypes.Array base and metaclass #5620

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

Merged
merged 4 commits into from
Mar 27, 2025
Merged

Conversation

youknowone
Copy link
Member

@arihant2math could you review this PR?

@youknowone youknowone requested a review from coolreader18 March 25, 2025 00:50
@youknowone youknowone changed the title Fix _ctypes.Array base and metacalss Fix _ctypes.Array base and metaclass Mar 25, 2025
@arihant2math arihant2math mentioned this pull request Mar 25, 2025
28 tasks
Copy link
Collaborator

@arihant2math arihant2math left a comment

Choose a reason for hiding this comment

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

The following causes different results in python and this branch:

from _ctypes import _SimpleCData

class c_short(_SimpleCData):
    _type_ = "h"
print(c_short.__mul__(5))

Python:

<class '__main__.c_short_Array_5'>

RustPython:

Traceback (most recent call last):
  File "tmp.py", line 6, in <module>
    print(c_short.__mul__(5))
TypeError: unexpected payload for __repr__

Note that on main the repr is simply incorrect (I haven't checked explicitly, but in previous testing, that is what I saw).

I don't think the cpython implementation PyCArrayType does anything special, so I assume this is a general rustpython compatibility.

@youknowone
Copy link
Member Author

ah, this is #1979

@arihant2math
Copy link
Collaborator

That seems to no longer occur for that case, but I suppose there might have been a bug in that patch.

@youknowone youknowone merged commit cd89aa5 into RustPython:main Mar 27, 2025
11 checks passed
@youknowone youknowone deleted the ctypes branch March 27, 2025 10:45
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.

3 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy