Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
029656fb
Commit
029656fb
authored
Jun 30, 2008
by
Martin v. Löwis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #3236: Return small longs from PyLong_FromString.
parent
2f5799b7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
0 deletions
+13
-0
Lib/test/test_int.py
Lib/test/test_int.py
+3
-0
Misc/NEWS
Misc/NEWS
+2
-0
Objects/longobject.c
Objects/longobject.c
+8
-0
No files found.
Lib/test/test_int.py
View file @
029656fb
...
...
@@ -95,6 +95,9 @@ class IntTestCases(unittest.TestCase):
self
.
assertRaises
(
ValueError
,
int
,
"0b"
,
2
)
self
.
assertRaises
(
ValueError
,
int
,
"0b"
,
0
)
# Bug #3236: Return small longs from PyLong_FromString
self
.
assert_
(
int
(
"10"
)
is
10
)
self
.
assert_
(
int
(
"-1"
)
is
-
1
)
# SF bug 1334662: int(string, base) wrong answers
# Various representations of 2**32 evaluated to 0
...
...
Misc/NEWS
View file @
029656fb
...
...
@@ -12,6 +12,8 @@ What's new in Python 3.0b2?
Core and Builtins
-----------------
- Issue #3236: Return small longs from PyLong_FromString.
Library
-------
...
...
Objects/longobject.c
View file @
029656fb
...
...
@@ -1981,6 +1981,14 @@ digit beyond the first.
goto
onError
;
if
(
pend
)
*
pend
=
str
;
long_normalize
(
z
);
if
(
ABS
(
Py_SIZE
(
z
))
<=
1
)
{
long
res
=
MEDIUM_VALUE
(
z
);
if
(
-
NSMALLPOSINTS
<=
res
&&
res
<=
NSMALLPOSINTS
)
{
Py_DECREF
(
z
);
return
PyLong_FromLong
(
res
);
}
}
return
(
PyObject
*
)
z
;
onError:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment