New submission from Oren Milman:
------------ current state ------------
In Objects/longobject.c, the function maybe_small_long first checks whether v
(the received PyLongObject pointer) is not NULL.
However, currently in every call to maybe_small_long, it is already guaranteed
that v is not NULL, which makes that check redundant.
(Currently, the following are the only functions that call maybe_small_long:
* PyLong_FromString
* long_divrem
* long_rshift
* long_lshift
* long_bitwise)
With regard to relevant changes made in the past, maybe_small_long remained
quite the same since it was added, in changeset 48567
(https://hg.python.org/cpython/rev/1ce7e5c5a761) - in particular, the check
(whether v is not NULL) was always there.
When it was added, both long_rshift and long_lshift might have called
maybe_small_long with v as NULL, which seems like the reason for adding the
check back then.
------------ proposed changes ------------
In Objects/longobject.c in maybe_small_long, remove the check whether v is not
NULL, and add an 'assert(v != NULL);'.
------------ diff ------------
The proposed patches diff file is attached.
------------ tests ------------
I ran 'python_d.exe -m test -j3' (on my 64-bit Windows 10) with and without the
patches, and got quite the same output.
The outputs of both runs are attached.
----------
components: Interpreter Core
files: CPythonTestOutput.txt
messages: 277371
nosy: Oren Milman
priority: normal
severity: normal
status: open
title: a redundant check in maybe_small_long
type: enhancement
versions: Python 3.7
Added file: http://bugs.python.org/file44815/CPythonTestOutput.txt
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue28272>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com