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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gwenaël Samain
cython
Commits
5626e87b
Commit
5626e87b
authored
Nov 27, 2009
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Plain Diff
merge
parents
600d3302
85bdf910
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
60 additions
and
18 deletions
+60
-18
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+1
-1
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+4
-1
runtests.py
runtests.py
+3
-1
tests/errors/builtin_type_conflict_T170.pyx
tests/errors/builtin_type_conflict_T170.pyx
+0
-15
tests/run/extern_builtins_T258.pyx
tests/run/extern_builtins_T258.pyx
+52
-0
No files found.
Cython/Compiler/ExprNodes.py
View file @
5626e87b
...
...
@@ -917,7 +917,7 @@ class StringNode(PyConstNode):
is_identifier
=
None
def
coerce_to
(
self
,
dst_type
,
env
):
if
dst_type
is
not
py_object_type
and
dst_type
is
not
str_type
:
if
dst_type
is
not
py_object_type
and
not
str_type
.
subtype_of
(
dst_type
)
:
# if dst_type is Builtin.bytes_type:
# # special case: bytes = 'str literal'
# return BytesNode(self.pos, value=self.value)
...
...
Cython/Compiler/PyrexTypes.py
View file @
5626e87b
...
...
@@ -400,8 +400,11 @@ class BuiltinObjectType(PyObjectType):
return
src_type
.
name
==
self
.
name
or
(
src_type
.
name
==
self
.
alternative_name
and
src_type
.
name
is
not
None
)
elif
src_type
.
is_extension_type
:
return
(
src_type
.
module_name
==
'__builtin__'
and
src_type
.
name
==
self
.
name
)
else
:
return
not
src_type
.
is_extension_typ
e
return
Tru
e
def
typeobj_is_available
(
self
):
return
True
...
...
runtests.py
View file @
5626e87b
...
...
@@ -856,7 +856,7 @@ if __name__ == '__main__':
os
.
path
.
join
(
sys
.
prefix
,
'lib'
,
'python'
+
sys
.
version
[:
3
],
'test'
),
'pyregr'
))
unittest
.
TextTestRunner
(
verbosity
=
options
.
verbosity
).
run
(
test_suite
)
result
=
unittest
.
TextTestRunner
(
verbosity
=
options
.
verbosity
).
run
(
test_suite
)
if
options
.
coverage
:
coverage
.
stop
()
...
...
@@ -875,3 +875,5 @@ if __name__ == '__main__':
if
options
.
with_refnanny
:
import
refnanny
sys
.
stderr
.
write
(
"
\
n
"
.
join
([
repr
(
x
)
for
x
in
refnanny
.
reflog
]))
sys
.
exit
(
not
result
.
wasSuccessful
())
tests/errors/builtin_type_conflict_T170.pyx
deleted
100644 → 0
View file @
600d3302
cdef
extern
from
*
:
ctypedef
class
__builtin__
.
list
[
object
PyListObject
]:
pass
cdef
list
foo
=
[]
# This is too invasive for Python 0.11.x, re-enable in 0.12
NEW_ERRORS
=
u"""
:2:4: list already a builtin Cython type
"""
_ERRORS
=
u"""
5:16: Cannot coerce list to type 'list'
"""
tests/run/extern_builtins_T258.pyx
0 → 100644
View file @
5626e87b
cdef
extern
from
"Python.h"
:
ctypedef
class
__builtin__
.
str
[
object
PyStringObject
]:
cdef
long
ob_shash
ctypedef
class
__builtin__
.
list
[
object
PyListObject
]:
cdef
Py_ssize_t
ob_size
cdef
Py_ssize_t
allocated
ctypedef
class
__builtin__
.
dict
[
object
PyDictObject
]:
pass
cdef
str
s
=
"abc"
cdef
list
L
=
[
1
,
2
,
4
]
cdef
dict
d
=
{
'A'
:
'a'
}
def
test_list
(
list
L
):
"""
>>> test_list(range(10))
True
>>> class list_subclass(list): pass
>>> test_list(list_subclass([1,2,3]))
True
"""
return
L
.
ob_size
<=
L
.
allocated
def
test_str
(
str
s
):
"""
>>> test_str("abc")
True
>>> class str_subclass(str): pass
>>> test_str(str_subclass("xyz"))
True
"""
cdef
char
*
ss
=
s
return
hash
(
s
)
==
s
.
ob_shash
def
test_tuple
(
tuple
t
):
"""
Actual builtin types are restrictive wrt subclassing so optimizations can be safely performed.
>>> test_tuple((1,2))
2
>>> class tuple_subclass(tuple): pass
>>> test_tuple(tuple_subclass((1,2)))
Traceback (most recent call last):
...
TypeError: Argument 't' has incorrect type (expected tuple, got tuple_subclass)
"""
return
len
(
t
)
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