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
Boxiang Sun
cython
Commits
e5c86145
Commit
e5c86145
authored
Jul 17, 2010
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Plain Diff
merged in latest cython-devel
parents
b67d841c
8f8ef5cd
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
78 additions
and
68 deletions
+78
-68
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+15
-10
tests/run/cdef_members_T517.pyx
tests/run/cdef_members_T517.pyx
+14
-8
tests/run/contains_T455.pyx
tests/run/contains_T455.pyx
+10
-14
tests/run/dict_getitem.pyx
tests/run/dict_getitem.pyx
+1
-5
tests/run/inop.pyx
tests/run/inop.pyx
+7
-6
tests/run/list_pop.pyx
tests/run/list_pop.pyx
+2
-3
tests/run/notinop.pyx
tests/run/notinop.pyx
+2
-2
tests/run/tuple.pyx
tests/run/tuple.pyx
+4
-9
tests/run/tupleassign.pyx
tests/run/tupleassign.pyx
+6
-6
tests/run/typedfieldbug_T303.pyx
tests/run/typedfieldbug_T303.pyx
+2
-2
tests/run/unicodeliterals.pyx
tests/run/unicodeliterals.pyx
+7
-2
tests/run/withstat.pyx
tests/run/withstat.pyx
+8
-1
No files found.
Cython/Compiler/ExprNodes.py
View file @
e5c86145
...
...
@@ -3655,9 +3655,9 @@ class SequenceNode(ExprNode):
code
.
put_gotref
(
item
.
py_result
())
value_node
=
self
.
coerced_unpacked_items
[
i
]
value_node
.
generate_evaluation_code
(
code
)
code
.
put_error_if_neg
(
self
.
pos
,
"__Pyx_EndUnpack(%s)"
%
(
self
.
iterator
.
py_result
(
)))
code
.
put_error_if_neg
(
self
.
pos
,
"__Pyx_EndUnpack(%s, %d)"
%
(
self
.
iterator
.
py_result
(),
len
(
self
.
args
)))
if
debug_disposal_code
:
print
(
"UnpackNode.generate_assignment_code:"
)
print
(
"...generating disposal code for %s"
%
self
.
iterator
)
...
...
@@ -7228,11 +7228,16 @@ impl = """
raise_too_many_values_to_unpack
=
UtilityCode
(
proto
=
"""
static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(
voi
d);
static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(
Py_ssize_t expecte
d);
"""
,
impl
=
'''
static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(void) {
PyErr_SetString(PyExc_ValueError, "too many values to unpack");
static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
PyErr_Format(PyExc_ValueError,
#if PY_VERSION_HEX < 0x02050000
"too many values to unpack (expected %d)", (int)expected);
#else
"too many values to unpack (expected %zd)", expected);
#endif
}
'''
)
...
...
@@ -7265,7 +7270,7 @@ static void __Pyx_UnpackTupleError(PyObject *t, Py_ssize_t index) {
} else if (PyTuple_GET_SIZE(t) < index) {
__Pyx_RaiseNeedMoreValuesError(PyTuple_GET_SIZE(t));
} else {
__Pyx_RaiseTooManyValuesError();
__Pyx_RaiseTooManyValuesError(
index
);
}
}
"""
,
...
...
@@ -7277,7 +7282,7 @@ requires = [raise_none_iter_error_utility_code,
unpacking_utility_code
=
UtilityCode
(
proto
=
"""
static PyObject *__Pyx_UnpackItem(PyObject *, Py_ssize_t index); /*proto*/
static int __Pyx_EndUnpack(PyObject *); /*proto*/
static int __Pyx_EndUnpack(PyObject *
, Py_ssize_t expected
); /*proto*/
"""
,
impl
=
"""
static PyObject *__Pyx_UnpackItem(PyObject *iter, Py_ssize_t index) {
...
...
@@ -7290,11 +7295,11 @@ static PyObject *__Pyx_UnpackItem(PyObject *iter, Py_ssize_t index) {
return item;
}
static int __Pyx_EndUnpack(PyObject *iter) {
static int __Pyx_EndUnpack(PyObject *iter
, Py_ssize_t expected
) {
PyObject *item;
if ((item = PyIter_Next(iter))) {
Py_DECREF(item);
__Pyx_RaiseTooManyValuesError();
__Pyx_RaiseTooManyValuesError(
expected
);
return -1;
}
else if (!PyErr_Occurred())
...
...
tests/run/cdef_members_T517.pyx
View file @
e5c86145
...
...
@@ -28,15 +28,14 @@ __doc__ = u"""
>>> b = B()
>>> b.a0 #doctest: +ELLIPSIS
Traceback (most recent call last):
...
AttributeError: ...
>>> b.b0 #doctest: +ELLIPSIS
Traceback (most recent call last):
...
AttributeError: ...
>>> b.c0 #doctest: +ELLIPSIS
Traceback (most recent call last):
...
AttributeError: ...
>>> isinstance(b.a1, type(None))
...
...
@@ -56,28 +55,35 @@ True
>>> b.a1 is not b.a2
True
TYPE_FIXES_REQUIRED:
>>> b.b1 = 1 #doctest: +ELLIPSIS
Traceback (most recent call last):
...
TypeError: ...
>>> b.c1 = 1 #doctest: +ELLIPSIS
Traceback (most recent call last):
...
TypeError: ...
>>> b.a2 = None #doctest: +ELLIPSIS
Traceback (most recent call last):
...
AttributeError: ...
>>> b.b2 = [] #doctest: +ELLIPSIS
Traceback (most recent call last):
...
AttributeError: ...
>>> b.c2 = A() #doctest: +ELLIPSIS
Traceback (most recent call last):
...
AttributeError: ...
"""
import
sys
if
sys
.
version_info
<
(
2
,
5
):
__doc__
=
(
__doc__
.
split
(
'TYPE_FIXES_REQUIRED'
)[
0
]
+
__doc__
.
split
(
'TYPE_FIXES_REQUIRED'
)[
1
].
replace
(
'
\
n
AttributeError: ...'
,
'
\
n
TypeError: ...'
))
cdef
class
A
:
cdef
public
short
h
...
...
tests/run/contains_T455.pyx
View file @
e5c86145
...
...
@@ -13,15 +13,13 @@ def in_sequence(x, seq):
>>> in_sequence(1, {1:None})
True
>>> in_sequence(1, None)
>>> in_sequence(1, None)
# doctest: +ELLIPSIS
Traceback (most recent call last):
...
TypeError: argument of type 'NoneType' is not iterable
TypeError: ...iterable...
>>> in_sequence(1, 1)
>>> in_sequence(1, 1)
# doctest: +ELLIPSIS
Traceback (most recent call last):
...
TypeError: argument of type 'int' is not iterable
TypeError: ...iterable...
"""
return
x
in
seq
...
...
@@ -40,15 +38,13 @@ def not_in_sequence(x, seq):
>>> not_in_sequence(1, {1:None})
False
>>> not_in_sequence(1, None)
>>> not_in_sequence(1, None)
# doctest: +ELLIPSIS
Traceback (most recent call last):
...
TypeError: argument of type 'NoneType' is not iterable
TypeError: ...iterable...
>>> not_in_sequence(1, 1)
>>> not_in_sequence(1, 1)
# doctest: +ELLIPSIS
Traceback (most recent call last):
...
TypeError: argument of type 'int' is not iterable
TypeError: ...iterable...
"""
return
x
not
in
seq
...
...
@@ -83,10 +79,10 @@ def not_in_dict(k, dict dct):
def
cascaded
(
a
,
b
,
c
):
"""
>>> cascaded(1, 2, 3)
>>> cascaded(1, 2, 3)
# doctest: +ELLIPSIS
Traceback (most recent call last):
...
TypeError:
argument of type 'int' is not iterable
TypeError:
...iterable...
>>> cascaded(-1, (1,2), (1,3))
True
>>> cascaded(1, (1,2), (1,3))
...
...
tests/run/dict_getitem.pyx
View file @
e5c86145
...
...
@@ -6,12 +6,10 @@ def test(dict d, index):
>>> test(d, 2)
Traceback (most recent call last):
...
KeyError: 2
>>> test(d, (1,2))
Traceback (most recent call last):
...
KeyError: (1, 2)
>>> class Unhashable:
...
...
@@ -19,13 +17,11 @@ def test(dict d, index):
... raise ValueError
>>> test(d, Unhashable())
Traceback (most recent call last):
...
ValueError
>>> test(None, 1) # doctest: +ELLIPSIS
Traceback (most recent call last):
...
TypeError: 'NoneType' object is ...
TypeError: ...subscriptable...
"""
return
d
[
index
]
...
...
tests/run/inop.pyx
View file @
e5c86145
...
...
@@ -103,9 +103,9 @@ def m_bytes(char a, bytes bytes_string):
1
>>> m_bytes(ord('X'), py_bytes_string)
0
>>> 'f'.encode('ASCII') in None
>>> 'f'.encode('ASCII') in None
# doctest: +ELLIPSIS
Traceback (most recent call last):
TypeError:
argument of type 'NoneType' is not iterable
TypeError:
...iterable...
>>> m_bytes(ord('f'), None)
Traceback (most recent call last):
TypeError: argument of type 'NoneType' is not iterable
...
...
@@ -121,9 +121,9 @@ def m_bytes_unsigned(unsigned char a, bytes bytes_string):
1
>>> m_bytes(ord('X'), py_bytes_string)
0
>>> 'f'.encode('ASCII') in None
>>> 'f'.encode('ASCII') in None
# doctest: +ELLIPSIS
Traceback (most recent call last):
TypeError:
argument of type 'NoneType' is not iterable
TypeError:
...iterable...
>>> m_bytes(ord('f'), None)
Traceback (most recent call last):
TypeError: argument of type 'NoneType' is not iterable
...
...
@@ -168,9 +168,10 @@ def m_unicode(Py_UNICODE a, unicode unicode_string):
0
>>> m_unicode(ord(py_klingon_character), py_unicode_string)
1
>>> 'f' in None
>>> 'f' in None # doctest: +ELLIPSIS
Traceback (most recent call last):
TypeError:
argument of type 'NoneType' is not iterable
TypeError:
...iterable...
>>> m_unicode(ord('f'), None)
Traceback (most recent call last):
TypeError: argument of type 'NoneType' is not iterable
...
...
tests/run/list_pop.pyx
View file @
e5c86145
...
...
@@ -129,10 +129,9 @@ def index_pop_typed(list L, int i):
@
cython
.
test_fail_if_path_exists
(
'//PythonCapiCallNode'
)
def
crazy_pop
(
L
):
"""
>>> crazy_pop(list(range(10)))
>>> crazy_pop(list(range(10)))
# doctest: +ELLIPSIS
Traceback (most recent call last):
...
TypeError: pop() takes at most 1 argument (3 given)
TypeError: pop... at most 1 argument...3...
>>> crazy_pop(A())
(1, 2, 3)
"""
...
...
tests/run/notinop.pyx
View file @
e5c86145
...
...
@@ -136,9 +136,9 @@ def m_unicode(Py_UNICODE a, unicode unicode_string):
1
>>> m_unicode(ord(py_klingon_character), py_unicode_string)
0
>>> 'f' in None
>>> 'f' in None
# doctest: +ELLIPSIS
Traceback (most recent call last):
TypeError:
argument of type 'NoneType' is not iterable
TypeError:
...iterable...
>>> m_unicode(ord('f'), None)
Traceback (most recent call last):
TypeError: argument of type 'NoneType' is not iterable
...
...
tests/run/tuple.pyx
View file @
e5c86145
import
sys
if
sys
.
version_info
<
(
2
,
5
):
__doc__
=
__doc__
.
replace
(
u"'NoneType' object is not iterable
\
n
>>> tuple_none_list()"
,
u'iteration over non-sequence
\
n
>>> tuple_none_list()'
)
def
f
(
obj1
,
obj2
,
obj3
,
obj4
,
obj5
):
"""
...
...
@@ -69,17 +64,17 @@ def l(obj1, obj2, obj3, obj4, obj5):
def
tuple_none
():
"""
>>> tuple_none()
>>> tuple_none()
# doctest: +ELLIPSIS
Traceback (most recent call last):
TypeError:
'NoneType' object is not iterable
TypeError:
...itera...
"""
return
tuple
(
None
)
def
tuple_none_list
():
"""
>>> tuple_none_list()
>>> tuple_none_list()
# doctest: +ELLIPSIS
Traceback (most recent call last):
TypeError:
'NoneType' object is not iterable
TypeError:
...iterable...
"""
cdef
list
none
=
None
return
tuple
(
none
)
tests/run/tupleassign.pyx
View file @
e5c86145
...
...
@@ -15,7 +15,7 @@ def assign3(t):
ValueError: need more than 2 values to unpack
>>> assign3((1,2,3,4))
Traceback (most recent call last):
ValueError: too many values to unpack
ValueError: too many values to unpack
(expected 3)
"""
a
,
b
,
c
=
t
return
(
a
,
b
,
c
)
...
...
@@ -39,16 +39,16 @@ def assign3_typed(tuple t):
>>> assign3_typed((1,2))
Traceback (most recent call last):
ValueError: need more than 2 values to unpack
>>> a,b,c = (1,2,3,4)
>>> a,b,c = (1,2,3,4)
# doctest: +ELLIPSIS
Traceback (most recent call last):
ValueError: too many values to unpack
ValueError: too many values to unpack
...
>>> assign3_typed((1,2,3,4))
Traceback (most recent call last):
ValueError: too many values to unpack
ValueError: too many values to unpack
(expected 3)
>>> a,b = 99,98
>>> a,b = t
>>> a,b = t
# doctest: +ELLIPSIS
Traceback (most recent call last):
ValueError: too many values to unpack
ValueError: too many values to unpack
...
>>> a,b
(99, 98)
"""
...
...
tests/run/typedfieldbug_T303.pyx
View file @
e5c86145
...
...
@@ -6,8 +6,8 @@ TypeError: ...
"""
import
sys
if
sys
.
version_info
[
0
:
2
]
>=
(
2
,
4
):
__doc__
=
__doc__
.
replace
(
u'TypeError:'
,
u
'AttributeError:'
)
if
sys
.
version_info
>=
(
2
,
5
):
__doc__
=
__doc__
.
replace
(
'TypeError:'
,
'AttributeError:'
)
cdef
extern
from
"external_defs.h"
:
...
...
tests/run/unicodeliterals.pyx
View file @
e5c86145
...
...
@@ -67,12 +67,17 @@ __doc__ = br"""
True
>>> null == u'
\
\
x00' # unescaped by Python (required by doctest)
True
>>> wide_literal == u'
\
U00101234
' # unescaped by Cython
True
>>> wide_literal == u'
\
\
U00101234' # unescaped by Python
True
"""
if
sys
.
version_info
>=
(
2
,
6
):
# this doesn't work well in older Python versions
__doc__
+=
u"""
\
>>> wide_literal == u'
\
U00101234
' # unescaped by Cython
True
"""
if
sys
.
version_info
[
0
]
>=
3
:
__doc__
=
__doc__
.
replace
(
u" u'"
,
u" '"
)
else
:
...
...
tests/run/withstat.pyx
View file @
e5c86145
from
__future__
import
with_statement
import
sys
def
typename
(
t
):
return
u"<type '%s'>"
%
type
(
t
).
__name__
name
=
type
(
t
).
__name__
if
sys
.
version_info
<
(
2
,
5
):
if
name
==
'classobj'
and
issubclass
(
t
,
MyException
):
name
=
'type'
elif
name
==
'instance'
and
isinstance
(
t
,
MyException
):
name
=
'MyException'
return
u"<type '%s'>"
%
name
class
MyException
(
Exception
):
pass
...
...
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