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
9a359bd9
Commit
9a359bd9
authored
Apr 20, 2012
by
Mark Dickinson
Browse files
Options
Browse Files
Download
Plain Diff
Issue #14630: Merge fix from 3.2.
parents
e2846548
bcc17eef
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
3 deletions
+18
-3
Lib/test/test_long.py
Lib/test/test_long.py
+14
-0
Misc/NEWS
Misc/NEWS
+3
-0
Objects/longobject.c
Objects/longobject.c
+1
-3
No files found.
Lib/test/test_long.py
View file @
9a359bd9
...
...
@@ -1228,6 +1228,20 @@ class LongTest(unittest.TestCase):
self
.
assertRaises
(
TypeError
,
myint
.
from_bytes
,
0
,
'big'
)
self
.
assertRaises
(
TypeError
,
int
.
from_bytes
,
0
,
'big'
,
True
)
def
test_access_to_nonexistent_digit_0
(
self
):
# http://bugs.python.org/issue14630: A bug in _PyLong_Copy meant that
# ob_digit[0] was being incorrectly accessed for instances of a
# subclass of int, with value 0.
class
Integer
(
int
):
def
__new__
(
cls
,
value
=
0
):
self
=
int
.
__new__
(
cls
,
value
)
self
.
foo
=
'foo'
return
self
integers
=
[
Integer
(
0
)
for
i
in
range
(
1000
)]
for
n
in
map
(
int
,
integers
):
self
.
assertEqual
(
n
,
0
)
def
test_main
():
support
.
run_unittest
(
LongTest
)
...
...
Misc/NEWS
View file @
9a359bd9
...
...
@@ -10,6 +10,9 @@ What's New in Python 3.3.0 Alpha 3?
Core and Builtins
-----------------
- Issue #14630: Fix a memory access bug for instances of a subclass of int
with value 0.
- Issue #14339: Speed improvements to bin, oct and hex functions. Patch by
Serhiy Storchaka.
...
...
Objects/longobject.c
View file @
9a359bd9
...
...
@@ -156,9 +156,7 @@ _PyLong_Copy(PyLongObject *src)
if
(
i
<
0
)
i
=
-
(
i
);
if
(
i
<
2
)
{
sdigit
ival
=
src
->
ob_digit
[
0
];
if
(
Py_SIZE
(
src
)
<
0
)
ival
=
-
ival
;
sdigit
ival
=
MEDIUM_VALUE
(
src
);
CHECK_SMALL_INT
(
ival
);
}
result
=
_PyLong_New
(
i
);
...
...
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