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.

Title: Unifying Long Integers and Integers in 2.7
Type: Stage: resolved
Components: Extension Modules, Library (Lib) Versions: Python 2.7
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: serhiy.storchaka Nosy List: benjamin.peterson, python-dev, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2016-12-17 09:37 by serhiy.storchaka, last changed 2022-04-11 14:58 by admin. This issue is now closed.

File name Uploaded Description Edit
py2_int_long.diff serhiy.storchaka, 2016-12-17 09:48 review
py2_int_long_2.diff serhiy.storchaka, 2016-12-25 09:39 review
Messages (3)
msg283479 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-12-17 09:37
Since implementing PEP 237 (Unifying Long Integers and Integers) in Python 2.4 int and long instances became interchangeable. Virtually any function that needs an integer, accepts both int and long. But there are few places where only int is accepted. Since it is easy unintentionally convert int to long (add and subtract large int, or add 0L), this can lead to subtle errors in rare circumstances.

Proposed patch makes few places that accepted only int accepting long too. This mainly is changing isinstance(x, int) to isinstance(x, (int, long)).
msg283990 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-12-25 09:39
Added checks for errors in C code (they are needed even without supporting Python longs, PyInt_AsLong() can fail with Python ints) and a fast path for Python longs in PyInt_AsLong() (avoid creating temporary Python int).
msg284093 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-12-27 13:09
New changeset ffcb321ba9c0 by Serhiy Storchaka in branch '2.7':
Issue #28998: More APIs now support longs as well as ints.
Date User Action Args
2022-04-11 14:58:40adminsetgithub: 73184
2016-12-27 13:10:23serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2016-12-27 13:09:56python-devsetnosy: + python-dev
messages: + msg284093
2016-12-25 09:40:01serhiy.storchakasetfiles: + py2_int_long_2.diff
assignee: serhiy.storchaka
messages: + msg283990
2016-12-17 09:48:42serhiy.storchakasetfiles: + py2_int_long.diff
keywords: + patch
2016-12-17 09:37:38serhiy.storchakacreate