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
c5c45ac3
Commit
c5c45ac3
authored
Sep 10, 2020
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert obsolete 'Fix typedefs of types convertible to Python always infering to PyObject'
parent
e87d4e98
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
19 deletions
+12
-19
Cython/Compiler/TypeInference.py
Cython/Compiler/TypeInference.py
+12
-19
No files found.
Cython/Compiler/TypeInference.py
View file @
c5c45ac3
...
@@ -549,56 +549,49 @@ def aggressive_spanning_type(types, might_overflow, pos, scope):
...
@@ -549,56 +549,49 @@ def aggressive_spanning_type(types, might_overflow, pos, scope):
def
safe_spanning_type
(
types
,
might_overflow
,
pos
,
scope
):
def
safe_spanning_type
(
types
,
might_overflow
,
pos
,
scope
):
result_type
=
simply_type
(
reduce
(
find_spanning_type
,
types
),
pos
)
result_type
=
simply_type
(
reduce
(
find_spanning_type
,
types
),
pos
)
if
result_type
.
is_pyobject
:
# if the result type is a typedef, use the resolved type to make decisions
# but keep the unresolved type as the value to be returned
resolved_result_type
=
result_type
if
result_type
.
is_typedef
:
resolved_result_type
=
result_type
.
resolve
()
if
resolved_result_type
.
is_pyobject
:
# In theory, any specific Python type is always safe to
# In theory, any specific Python type is always safe to
# infer. However, inferring str can cause some existing code
# infer. However, inferring str can cause some existing code
# to break, since we are also now much more strict about
# to break, since we are also now much more strict about
# coercion from str to char *. See trac #553.
# coercion from str to char *. See trac #553.
if
res
olved_res
ult_type
.
name
==
'str'
:
if
result_type
.
name
==
'str'
:
return
py_object_type
return
py_object_type
else
:
else
:
return
result_type
return
result_type
elif
res
olved_res
ult_type
is
PyrexTypes
.
c_double_type
:
elif
result_type
is
PyrexTypes
.
c_double_type
:
# Python's float type is just a C double, so it's safe to use
# Python's float type is just a C double, so it's safe to use
# the C type instead
# the C type instead
return
result_type
return
result_type
elif
res
olved_res
ult_type
is
PyrexTypes
.
c_bint_type
:
elif
result_type
is
PyrexTypes
.
c_bint_type
:
# find_spanning_type() only returns 'bint' for clean boolean
# find_spanning_type() only returns 'bint' for clean boolean
# operations without other int types, so this is safe, too
# operations without other int types, so this is safe, too
return
result_type
return
result_type
elif
res
olved_res
ult_type
.
is_pythran_expr
:
elif
result_type
.
is_pythran_expr
:
return
result_type
return
result_type
elif
res
olved_res
ult_type
.
is_ptr
:
elif
result_type
.
is_ptr
:
# Any pointer except (signed|unsigned|) char* can't implicitly
# Any pointer except (signed|unsigned|) char* can't implicitly
# become a PyObject, and inferring char* is now accepted, too.
# become a PyObject, and inferring char* is now accepted, too.
return
result_type
return
result_type
elif
res
olved_res
ult_type
.
is_cpp_class
:
elif
result_type
.
is_cpp_class
:
# These can't implicitly become Python objects either.
# These can't implicitly become Python objects either.
return
result_type
return
result_type
elif
res
olved_res
ult_type
.
is_struct
:
elif
result_type
.
is_struct
:
# Though we have struct -> object for some structs, this is uncommonly
# Though we have struct -> object for some structs, this is uncommonly
# used, won't arise in pure Python, and there shouldn't be side
# used, won't arise in pure Python, and there shouldn't be side
# effects, so I'm declaring this safe.
# effects, so I'm declaring this safe.
return
result_type
return
result_type
elif
result_type
.
is_memoryviewslice
:
elif
result_type
.
is_memoryviewslice
:
return
result_type
return
result_type
elif
res
olved_res
ult_type
.
is_ctuple
:
elif
result_type
.
is_ctuple
:
# Since structs are considered safe, and ctuples are essentially structs
# Since structs are considered safe, and ctuples are essentially structs
# with tuple-like syntax, they should be safe for the same reasons.
# with tuple-like syntax, they should be safe for the same reasons.
return
result_type
return
result_type
# TODO: double complex should be OK as well, but we need
# TODO: double complex should be OK as well, but we need
# to make sure everything is supported.
# to make sure everything is supported.
elif
(
res
olved_result_type
.
is_int
or
resolved_
result_type
.
is_enum
)
and
not
might_overflow
:
elif
(
res
ult_type
.
is_int
or
result_type
.
is_enum
)
and
not
might_overflow
:
return
result_type
return
result_type
elif
(
not
res
olved_res
ult_type
.
can_coerce_to_pyobject
(
scope
)
elif
(
not
result_type
.
can_coerce_to_pyobject
(
scope
)
and
not
res
olved_res
ult_type
.
is_error
):
and
not
result_type
.
is_error
):
return
result_type
return
result_type
return
py_object_type
return
py_object_type
...
...
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