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
f93cf38b
Commit
f93cf38b
authored
Feb 18, 2003
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make PyNumber_Check() a bit more careful, since all sorts of things
now have tp_as_number. Check for nb_int or nb_float.
parent
3aeb9dd7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
1 deletion
+11
-1
Misc/NEWS
Misc/NEWS
+8
-0
Objects/abstract.c
Objects/abstract.c
+3
-1
No files found.
Misc/NEWS
View file @
f93cf38b
...
...
@@ -89,6 +89,10 @@ Core and builtins
Extension
modules
-----------------
-
operator
.
isNumberType
()
now
checks
that
the
object
has
a
nb_int
or
nb_float
slot
,
rather
than
simply
checking
whether
it
has
a
non
-
NULL
tp_as_number
pointer
.
-
The
imp
module
now
has
ways
to
acquire
and
release
the
"import
lock"
:
imp
.
acquire_lock
()
and
imp
.
release_lock
().
Note
:
this
is
a
reentrant
lock
,
so
releasing
the
lock
only
truly
releases
it
when
...
...
@@ -318,6 +322,10 @@ Build
C
API
-----
-
PyNumber_Check
()
now
checks
that
the
object
has
a
nb_int
or
nb_float
slot
,
rather
than
simply
checking
whether
it
has
a
non
-
NULL
tp_as_number
pointer
.
-
A
C
type
that
inherits
from
a
base
type
that
defines
tp_as_buffer
will
now
inherit
the
tp_as_buffer
pointer
if
it
doesn
't define one.
(SF #681367)
...
...
Objects/abstract.c
View file @
f93cf38b
...
...
@@ -308,7 +308,9 @@ int PyObject_AsWriteBuffer(PyObject *obj,
int
PyNumber_Check
(
PyObject
*
o
)
{
return
o
&&
o
->
ob_type
->
tp_as_number
;
return
o
&&
o
->
ob_type
->
tp_as_number
&&
(
o
->
ob_type
->
tp_as_number
->
nb_int
||
o
->
ob_type
->
tp_as_number
->
nb_float
);
}
/* Binary operators */
...
...
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