[issue4393] Portability fixes in longobject.c
report at bugs.python.org
Sun Nov 23 13:28:26 CET 2008
New submission from Mark Dickinson <dickinsm at gmail.com>:
This patch fixes 3 classes of bugs in Objects/longobject.c:
(1) declarations of a variable (usually a counter into the digits of
a PyLong) as int instead of Py_ssize_t.
(2) missing (twodigits) casts from multiplies and shifts.
(3) use of '<<' on negative values in _PyLong_AsByteArray. This
may lead to undefined behaviour, according to the C standards. (See C99,
section 6.5.7, paragraph 4).
These bugs haven't manifested themselves in practice. For (1), there's
only a problem when dealing with huge integers (more than 2**31 digits).
The bugs in (2) can only affect platform where the C 'int' type has fewer
than 32 bits. (3) could potentially conflict with future compiler
optimizations, but doesn't seem to be a problem right now.
For these reasons I don't think these fixes should be backported to 2.5.3.
components: Interpreter Core
stage: patch review
title: Portability fixes in longobject.c
versions: Python 2.6, Python 2.7, Python 3.0, Python 3.1
Added file: http://bugs.python.org/file12109/longobject_casts.patch
Python tracker <report at bugs.python.org>
More information about the Python-bugs-list