Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
9215510d
Commit
9215510d
authored
Jul 21, 2010
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix 'set' type checks (prevent match with frozenset)
parent
f972b042
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
9 deletions
+22
-9
Cython/Compiler/ModuleNode.py
Cython/Compiler/ModuleNode.py
+6
-0
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+16
-9
No files found.
Cython/Compiler/ModuleNode.py
View file @
9215510d
...
@@ -548,6 +548,12 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
...
@@ -548,6 +548,12 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
#define PyBytes_Repr PyString_Repr
#define PyBytes_Repr PyString_Repr
#define PyBytes_Concat PyString_Concat
#define PyBytes_Concat PyString_Concat
#define PyBytes_ConcatAndDel PyString_ConcatAndDel
#define PyBytes_ConcatAndDel PyString_ConcatAndDel
#define PySet_Check(obj) PyObject_TypeCheck(obj, &PySet_Type)
#define PyFrozenSet_Check(obj) PyObject_TypeCheck(obj, &PyFrozenSet_Type)
#endif
#ifndef PySet_CheckExact
# define PySet_CheckExact(obj) (Py_TYPE(obj) == PySet_Type)
#endif
#endif
#if PY_MAJOR_VERSION >= 3
#if PY_MAJOR_VERSION >= 3
...
...
Cython/Compiler/PyrexTypes.py
View file @
9215510d
...
@@ -416,20 +416,27 @@ class BuiltinObjectType(PyObjectType):
...
@@ -416,20 +416,27 @@ class BuiltinObjectType(PyObjectType):
def
subtype_of
(
self
,
type
):
def
subtype_of
(
self
,
type
):
return
type
.
is_pyobject
and
self
.
assignable_from
(
type
)
return
type
.
is_pyobject
and
self
.
assignable_from
(
type
)
def
type_
test_code
(
self
,
arg
,
notnone
=
Fals
e
):
def
type_
check_function
(
self
,
exact
=
Tru
e
):
type_name
=
self
.
name
type_name
=
self
.
name
if
type_name
==
'bool'
:
return
'PyBool_Check'
if
type_name
==
'str'
:
if
type_name
==
'str'
:
type_check
=
'PyString_CheckExact'
type_check
=
'PyString_Check'
elif
type_name
==
'set'
:
type_check
=
'PyAnySet_CheckExact'
elif
type_name
==
'frozenset'
:
elif
type_name
==
'frozenset'
:
type_check
=
'PyFrozenSet_CheckExact'
type_check
=
'PyFrozenSet_Check'
elif
type_name
==
'bool'
:
type_check
=
'PyBool_Check'
else
:
else
:
type_check
=
'Py%s_CheckExact'
%
type_name
.
capitalize
()
type_check
=
'Py%s_Check'
%
type_name
.
capitalize
()
if
exact
:
type_check
+=
'Exact'
return
type_check
def
isinstance_code
(
self
,
arg
):
return
'%s(%s)'
%
(
self
.
type_check_function
(
exact
=
False
),
arg
)
def
type_test_code
(
self
,
arg
,
notnone
=
False
):
type_check
=
self
.
type_check_function
(
exact
=
True
)
check
=
'likely(%s(%s))'
%
(
type_check
,
arg
)
check
=
'likely(%s(%s))'
%
(
type_check
,
arg
)
if
not
notnone
:
if
not
notnone
:
check
=
check
+
(
'||((%s) == Py_None)'
%
arg
)
check
=
check
+
(
'||((%s) == Py_None)'
%
arg
)
...
...
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