-
-
Notifications
You must be signed in to change notification settings - Fork 30.3k
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
bpo-39573: Use Py_SIZE() in s_set() of cfield.c #18419
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is unrelated to https://bugs.python.org/issue39573 If you consider that s_set() behavior is a bug, please open a separated issue.
Your change is backward incompatible. Example:
import ctypes
class MyStruct(ctypes.Structure):
_fields_ = (
('char', ctypes.c_char * 5),
)
s = MyStruct()
print(ascii(s.char), bytes(s))
s.char = b'a\0b\0'
print(ascii(s.char), bytes(s))
Current behavior:
b'' b'\x00\x00\x00\x00\x00'
b'a' b'a\x00\x00\x00\x00'
=> only b'a\0' (2 bytes) are copied
With your PR:
b'' b'\x00\x00\x00\x00\x00'
b'a' b'a\x00b\x00\x00'
=> only b'a\0b\0' (4 bytes) are copied
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
cc @corona10 |
Thanks for your quick feedback, victor.
I found you do some macro porting operations, so I thought this macro porting operation relate to 39573 is fine(not the cause of a bug).
Great example, current tests not help me found this backward incompatible and your example have answer this question( I have debug it in my vm, the reason is: Sorry for this noisy PR, guys! |
To prevent other developers break this backward incompatible again, i add victor's example in #18424 |
https://bugs.python.org/issue39573