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.

classification
Title: fix arraymodule for overflow checking
Type: Stage:
Components: None Versions:
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: fdrake Nosy List: fdrake, tmick
Priority: normal Keywords: patch

Created on 2000-06-07 02:34 by tmick, last changed 2022-04-10 16:02 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
None tmick, 2000-06-07 02:34 None
Messages (3)
msg32689 - (view) Author: Trent Mick (tmick) (Python triager) Date: 2000-06-07 02:34
 
msg32690 - (view) Author: Trent Mick (tmick) (Python triager) Date: 2000-06-07 02:34
I confirm that, to the best of my knowledge and belief, this
contribution is free of any claims of third parties under
copyright, patent or other rights or interests ("claims").  To
the extent that I have any such claims, I hereby grant to CNRI a
nonexclusive, irrevocable, royalty-free, worldwide license to
reproduce, distribute, perform and/or display publicly, prepare
derivative versions, and otherwise use this contribution as part
of the Python software and its related documentation, or any
derivative versions thereof, at no cost to CNRI or its licensed
users, and to authorize others to do so.

I acknowledge that CNRI may, at its sole discretion, decide
whether or not to incorporate this contribution in the Python
software and its related documentation.  I further grant CNRI
permission to use my name and other identifying information
provided to CNRI by me for use in connection with the Python
software and its related documentation.
msg32691 - (view) Author: Trent Mick (tmick) (Python triager) Date: 2000-06-07 02:36
The cause: Relatively recent (last month) patches to getargs.c added overflow
checking to the PyArg_Parse*() integral formatters thereby restricting 'b' to
unsigned char value and 'h','i', and 'l' to signed integral values (i.e. if
the incoming value is outside of the specified bounds you get an
OverflowError, previous it silently overflowed).

The problem: This broke the array module (as Fredrik pointed out) because
*its* formatters relied on the loose allowance of signed and unsigned ranges
being able to pass through PyArg_Parse*()'s formatters.

The fix: This patch fixes the array module to work with the more strict
bounds checking now in PyArg_Parse*().

How: If the type signature of a formatter in the arraymodule exactly matches
one in PyArg_Parse*(), then use that directly. If there is no equivalent type
signature in PyArg_Parse*() (e.g. there is no unsigned int formatter in
PyArg_Parse*()), then use the next one up and do some extra bounds checking
in the array module.

Testing: test_array.py was also extended to check that one can set the full
range of values for each of the integral signed and unsigned array types.
History
Date User Action Args
2022-04-10 16:02:00adminsetgithub: 32429
2000-06-07 02:34:11tmickcreate