This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: SystemError generated by struct.pack('P', 'notanumber')
Type: Stage:
Components: Extension Modules Versions:
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: Nosy List: arigo, ddorfman
Priority: normal Keywords: patch

Created on 2004-08-18 06:53 by ddorfman, last changed 2022-04-11 14:56 by admin. This issue is now closed.

File name Uploaded Description Edit
structP.diff ddorfman, 2004-08-18 06:53 Patch and failing test case
Messages (2)
msg46731 - (view) Author: Dima Dorfman (ddorfman) Date: 2004-08-18 06:53
Trying to use the struct module's 'P' format with a
non-numeric arguments yields a SystemError. When the P
format was implemented in rev 2.28, the get_pylong helper
wasn't available, so it was less obvious how do this
right. Now that the helper is available, it's straight-
forward to use it to ensure proper error reporting instead
of rolling our own. Interestingly, the comment in np_void_p
indicates that the author knew about this problem; my guess
is that they intended to fix it by changing PyLong_AsVoidPtr
to generate TypeError instead, but SystemError is the right
thing to do because it's consistent with the rest of the C
API, and get_pylong deals with this properly.

References: structmodule.c 2.28 and 2.47
msg46732 - (view) Author: Armin Rigo (arigo) * (Python committer) Date: 2004-09-27 19:28
Logged In: YES 

Seems reasonable.  Checked in as:

    Modules/structmodule.c 2.62
    Lib/test/ 1.19

I don't think we care about it, but for 32-bit platforms converting an int to a long and then to a void* is a waste.  We could special-case ints.  Not sure it's worth the trouble.
Date User Action Args
2022-04-11 14:56:06adminsetgithub: 40778
2004-08-18 06:53:33ddorfmancreate