-
-
Notifications
You must be signed in to change notification settings - Fork 31.4k
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
Undetected error in _struct.pack_into #47944
Comments
The following code leads to XXX Undetected errors in debug builds of import _struct
_struct.pack_into(b"8", bytearray(1), None) Besides that, there's something fishy happening in non-debug builds: 2.6:
>>> _struct.pack_into(b"8", bytearray(1), None);
>>> _struct.pack_into(b"8", bytearray(1), None);
>>> import sys
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: an integer is required
3.0:
>>> _struct.pack_into(b"8", bytearray(1), None)
>>> _struct.pack_into(b"8", bytearray(1), None)
SystemError: Objects/longobject.c:433: bad argument to internal function Found with Fusil. |
The problem is that, unlike PyInt_AsSsize_t, PyLong_AsSsize_t expects It should probably behave like PyInt_AsSsize_t and raise the TypeError |
The attached patches at least correct the XXX undetected error. |
Isn't PyNumber_AsSsize_t designed for this purpose? |
Yes, PyNumber_AsSsize_t() should be used instead. |
Oh, and a test should be added :) |
Here's a patch with test for 3.x. Erm, I have no idea if that's all that Does this have the potential to break existing code? |
Well, a patch for 2.6 should be provided as well. Besides, |
Looks like both Undetected errors were corrected by Victor's patches, I think IndexError fits better (and matches trunk), as the issue is that BTW, there's a warning in _struct.c:180 -> warning: ‘get_ulong’ defined |
Applied in r69577, r69578. |
Sure. Please could you add me to the nosy list if you do. In my opinion, the struct module *really* needs an overhaul, especially Would it be worth opening a general 'overhaul the struct module' issue |
OK, should do that soon.
This one looks bad: bpo-2590.
I can't judge on the merit of struct's shortcomings, but I'll propose |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: