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
79e555d0
Commit
79e555d0
authored
Mar 20, 2012
by
Benjamin Peterson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
correctly lookup __trunc__ in int() constructor
parent
5e80cb54
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
2 deletions
+4
-2
Lib/test/test_descr.py
Lib/test/test_descr.py
+1
-0
Objects/abstract.c
Objects/abstract.c
+3
-2
No files found.
Lib/test/test_descr.py
View file @
79e555d0
...
...
@@ -1770,6 +1770,7 @@ order (MRO) for bases """
(
"__format__"
,
format
,
format_impl
,
set
(),
{}),
(
"__floor__"
,
math
.
floor
,
zero
,
set
(),
{}),
(
"__trunc__"
,
math
.
trunc
,
zero
,
set
(),
{}),
(
"__trunc__"
,
int
,
zero
,
set
(),
{}),
(
"__ceil__"
,
math
.
ceil
,
zero
,
set
(),
{}),
(
"__dir__"
,
dir
,
empty_seq
,
set
(),
{}),
]
...
...
Objects/abstract.c
View file @
79e555d0
...
...
@@ -1350,7 +1350,7 @@ PyNumber_Long(PyObject *o)
}
if
(
PyLong_Check
(
o
))
/* An int subclass without nb_int */
return
_PyLong_Copy
((
PyLongObject
*
)
o
);
trunc_func
=
_PyObject_
GetAttrId
(
o
,
&
PyId___trunc__
);
trunc_func
=
_PyObject_
LookupSpecial
(
o
,
&
PyId___trunc__
);
if
(
trunc_func
)
{
PyObject
*
truncated
=
PyEval_CallObject
(
trunc_func
,
NULL
);
PyObject
*
int_instance
;
...
...
@@ -1362,7 +1362,8 @@ PyNumber_Long(PyObject *o)
"__trunc__ returned non-Integral (type %.200s)"
);
return
int_instance
;
}
PyErr_Clear
();
/* It's not an error if o.__trunc__ doesn't exist. */
if
(
PyErr_Occurred
())
return
NULL
;
if
(
PyBytes_Check
(
o
))
/* need to do extra error checking that PyLong_FromString()
...
...
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