1t = (1,2,3)
2l = [1,2,3]
3
4def assign3(t):
5    """
6    >>> assign3(l)
7    (1, 2, 3)
8    >>> assign3(t)
9    (1, 2, 3)
10    >>> assign3((1,))
11    Traceback (most recent call last):
12    ValueError: need more than 1 value to unpack
13    >>> assign3((1,2))
14    Traceback (most recent call last):
15    ValueError: need more than 2 values to unpack
16    >>> assign3((1,2,3,4))
17    Traceback (most recent call last):
18    ValueError: too many values to unpack (expected 3)
19    """
20    a,b,c = t
21    return (a,b,c)
22
23def assign3_typed(tuple t):
24    """
25    >>> assign3_typed(t)
26    (1, 2, 3)
27    >>> assign3_typed(l)
28    Traceback (most recent call last):
29    TypeError: Argument 't' has incorrect type (expected tuple, got list)
30    >>> a,b,c = (1,) # doctest: +ELLIPSIS
31    Traceback (most recent call last):
32    ValueError: ...
33    >>> assign3_typed((1,))
34    Traceback (most recent call last):
35    ValueError: need more than 1 value to unpack
36    >>> a,b,c = (1,2) # doctest: +ELLIPSIS
37    Traceback (most recent call last):
38    ValueError: ...
39    >>> assign3_typed((1,2))
40    Traceback (most recent call last):
41    ValueError: need more than 2 values to unpack
42    >>> a,b,c = (1,2,3,4)    # doctest: +ELLIPSIS
43    Traceback (most recent call last):
44    ValueError: ...
45    >>> assign3_typed((1,2,3,4))
46    Traceback (most recent call last):
47    ValueError: too many values to unpack (expected 3)
48    >>> a,b = 99,98
49    >>> a,b = t     # doctest: +ELLIPSIS
50    Traceback (most recent call last):
51    ValueError: ...
52    >>> a,b
53    (99, 98)
54    """
55    a,b,c = t
56    return (a,b,c)
57
58def assign3_int(t):
59    """
60    >>> assign3_int(l)
61    (1, 2, 3)
62    """
63    cdef int a,b,c
64    a,b,c = t
65    return (a,b,c)
66
67def assign3_mixed1(t):
68    """
69    >>> assign3_mixed1(l)
70    (1, 2, 3)
71    """
72    cdef int a
73    a,b,c = t
74    return (a,b,c)
75
76def assign3_mixed2(t):
77    """
78    >>> assign3_mixed2(l)
79    (1, 2, 3)
80    """
81    cdef int b
82    a,b,c = t
83    return (a,b,c)
84
85def assign3_mixed3(t):
86    """
87    >>> assign3_mixed3(l)
88    (1, 2, 3)
89    """
90    cdef int c
91    a,b,c = t
92    return (a,b,c)
93
94def assign3_mixed4(t):
95    cdef int b,c
96    a,b,c = t
97    return (a,b,c)
98
99def test_overwrite(t):
100    """
101    >>> test_overwrite(l)
102    (99, 98)
103    >>> test_overwrite(t)
104    (99, 98)
105    """
106    a,b = 99,98
107    try:
108        a,b = t
109    except ValueError:
110        pass
111    return (a,b)
112
113def test_overwrite_int(t):
114    """
115    >>> test_overwrite_int(l)
116    (99, 98)
117    >>> test_overwrite_int(t)
118    (99, 98)
119    """
120    cdef int a,b
121    a,b = 99,98
122    try:
123        a,b = t
124    except ValueError:
125        pass
126    return (a,b)
127
128def test_overwrite_mixed(t):
129    """
130    >>> test_overwrite_mixed(l)
131    (99, 98)
132    >>> test_overwrite_mixed(t)
133    (99, 98)
134    """
135    cdef int b
136    a,b = 99,98
137    try:
138        a,b = t
139    except ValueError:
140        pass
141    return (a,b)
142
143def test_overwrite_mixed2(t):
144    """
145    >>> test_overwrite_mixed2(l)
146    (99, 98)
147    >>> test_overwrite_mixed2(t)
148    (99, 98)
149    """
150    cdef int a
151    a,b = 99,98
152    try:
153        a,b = t
154    except ValueError:
155        pass
156    return (a,b)
157