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
85bdf910
Commit
85bdf910
authored
Nov 27, 2009
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tests for #258.
parent
80135d83
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
15 deletions
+52
-15
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.
tests/errors/builtin_type_conflict_T170.pyx
deleted
100644 → 0
View file @
80135d83
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 @
85bdf910
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