Author Oren Milman
Recipients Oren Milman
Date 2016-09-25.12:38:48
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
------------ 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 ( - 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.
Date User Action Args
2016-09-25 12:38:54Oren Milmansetrecipients: + Oren Milman
2016-09-25 12:38:49Oren Milmansetmessageid: <>
2016-09-25 12:38:49Oren Milmanlinkissue28272 messages
2016-09-25 12:38:49Oren Milmancreate