Issue 9696: xdrlib's pack_int generates DeprecationWarnings for negative in-range values (original) (raw)

Created on 2010-08-26 22:05 by dep, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
9696.patch gruszczy,2011-03-27 09:59 review
Messages (10)
msg115034 - (view) Author: David Powell (dep) Date: 2010-08-26 22:05
The problem is easy to reproduce: >>> import xdrlib >>> p = xdrlib.Packer() >>> p.pack_int(-1) __main__:1: DeprecationWarning: struct integer overflow masking is deprecated The cause is xdrlib.Packer uses the same pack operation for both signed and unsigned integers... def pack_uint(self, x): self.__buf.write(struct.pack('>L', x)) pack_int = pack_uint ...and the unsigned struct.pack('>L', x) gags on the negative value.
msg115047 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-08-27 00:05
Thanks for the report. This actually raises an error with current Pythons: 2.7 traceback: File "xdrlib.py", line 54, in pack_uint self.__buf.write(struct.pack('>L', x)) struct.error: integer out of range for 'L' format code (The 3.x error message is slightly less helpful: “struct.error: argument out of range”). Would you like to make a patch for this? Bug triage tips: 2.6 only gets security fixes, bugs are not fixed there anymore. “Extension modules” are modules written in C, like time; Python modules map to the “Library” component.
msg132302 - (view) Author: Filip Gruszczyński (gruszczy) Date: 2011-03-27 09:59
Here is a test and a patch.
msg132334 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2011-03-27 15:12
Patch looks good to me. Thanks!
msg132335 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-03-27 15:15
New changeset d3f9a6d7f6e4 by Mark Dickinson in branch '2.7': Issue #9696: Fix exception incorrectly raised by xdrlib.Packer.pack_int when trying to pack a negative (in-range) integer. http://hg.python.org/cpython/rev/d3f9a6d7f6e4
msg132337 - (view) Author: Filip Gruszczyński (gruszczy) Date: 2011-03-27 15:32
I believe this should be applied also against 3.3. I was working on this using 3.3 code base, so it is not working there too.
msg132340 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2011-03-27 15:35
Patience! I'm getting there...
msg132342 - (view) Author: Filip Gruszczyński (gruszczy) Date: 2011-03-27 15:37
I'm sorry, I wasn't hurrying you. Just wanted to make sure you know.
msg132344 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-03-27 15:39
New changeset bd5e821f201c by Mark Dickinson in branch '3.1': Issue #9696: Fix exception incorrectly raised by xdrlib.Packer.pack_int when trying to pack a negative (in-range) integer. http://hg.python.org/cpython/rev/bd5e821f201c New changeset 391b2ddbc1b7 by Mark Dickinson in branch '3.2': Merge #9696 http://hg.python.org/cpython/rev/391b2ddbc1b7 New changeset d9b64a86d5a7 by Mark Dickinson in branch 'default': Merge #9696 http://hg.python.org/cpython/rev/d9b64a86d5a7
msg132345 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2011-03-27 15:41
> I'm sorry, I wasn't hurrying you. Just wanted to make sure you know. No problem :-). Thanks for the fix!
History
Date User Action Args
2022-04-11 14:57:05 admin set github: 53905
2011-03-27 15:41:36 mark.dickinson set status: open -> closedversions: + Python 3.3messages: + resolution: fixedstage: resolved
2011-03-27 15:39:59 python-dev set messages: +
2011-03-27 15:37:05 gruszczy set messages: +
2011-03-27 15:35:31 mark.dickinson set messages: +
2011-03-27 15:32:42 gruszczy set messages: +
2011-03-27 15:15:29 python-dev set nosy: + python-devmessages: +
2011-03-27 15:12:37 mark.dickinson set assignee: mark.dickinsonmessages: +
2011-03-27 09:59:59 gruszczy set files: + 9696.patchnosy: + gruszczymessages: + keywords: + patch
2010-08-28 08:05:34 mark.dickinson set nosy: + mark.dickinson
2010-08-27 00:05:56 eric.araujo set versions: + Python 3.1, Python 2.7, Python 3.2, - Python 2.6nosy: + eric.araujomessages: + components: + Library (Lib), - Extension Modules
2010-08-26 22:05:01 dep create