Commit e5c86145 authored by Stefan Behnel's avatar Stefan Behnel

merged in latest cython-devel

parents b67d841c 8f8ef5cd
......@@ -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(void);
static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);
""",
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())
......
......@@ -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('\nAttributeError: ...', '\nTypeError: ...'))
cdef class A:
cdef public short h
......
......@@ -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))
......
......@@ -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]
......
......@@ -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
......
......@@ -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)
"""
......
......@@ -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
......
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)
......@@ -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)
"""
......
......@@ -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":
......
......@@ -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:
......
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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment