[Patches] [ python-Patches-1011240 ] SystemError generated by
struct.pack('P', 'notanumber')
SourceForge.net
noreply at sourceforge.net
Mon Sep 27 21:28:29 CEST 2004
Patches item #1011240, was opened at 2004-08-18 06:53
Message generated for change (Comment added) made by arigo
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1011240&group_id=5470
Category: Modules
Group: None
>Status: Closed
>Resolution: Accepted
Priority: 5
Submitted By: Dima Dorfman (ddorfman)
Assigned to: Nobody/Anonymous (nobody)
Summary: SystemError generated by struct.pack('P', 'notanumber')
Initial Comment:
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
----------------------------------------------------------------------
>Comment By: Armin Rigo (arigo)
Date: 2004-09-27 19:28
Message:
Logged In: YES
user_id=4771
Seems reasonable. Checked in as:
Modules/structmodule.c 2.62
Lib/test/test_struct.py 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.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1011240&group_id=5470
More information about the Patches
mailing list