diff options
| author | Martin Panter <vadmium+py@gmail.com> | 2016-01-31 06:33:16 (GMT) |
|---|---|---|
| committer | Martin Panter <vadmium+py@gmail.com> | 2016-01-31 06:33:16 (GMT) |
| commit | cca32995b35aa9c371459e19caaa003d1e761b8a (patch) | |
| tree | 4ce436cb6c552a3088fb3501519753852daff4c2 /Lib/test/test_extcall.py | |
| parent | 03178a5f7eb7af39b07ef43834c815ade6a394e6 (diff) | |
| parent | b5944220abaa525d326b6054b213adcdb26e7fda (diff) | |
| download | cpython-cca32995b35aa9c371459e19caaa003d1e761b8a.zip cpython-cca32995b35aa9c371459e19caaa003d1e761b8a.tar.gz cpython-cca32995b35aa9c371459e19caaa003d1e761b8a.tar.bz2 | |
Issue #4806: Merge * unpacking fix from 3.5
Diffstat (limited to 'Lib/test/test_extcall.py')
| -rw-r--r-- | Lib/test/test_extcall.py | 49 |
1 files changed, 44 insertions, 5 deletions
diff --git a/Lib/test/test_extcall.py b/Lib/test/test_extcall.py index 654258e..d526b5f 100644 --- a/Lib/test/test_extcall.py +++ b/Lib/test/test_extcall.py @@ -114,7 +114,7 @@ Verify clearing of SF bug #733667 >>> g(*Nothing()) Traceback (most recent call last): ... - TypeError: g() argument after * must be a sequence, not Nothing + TypeError: g() argument after * must be an iterable, not Nothing >>> class Nothing: ... def __len__(self): return 5 @@ -123,7 +123,7 @@ Verify clearing of SF bug #733667 >>> g(*Nothing()) Traceback (most recent call last): ... - TypeError: g() argument after * must be a sequence, not Nothing + TypeError: g() argument after * must be an iterable, not Nothing >>> class Nothing(): ... def __len__(self): return 5 @@ -149,6 +149,45 @@ Verify clearing of SF bug #733667 >>> g(*Nothing()) 0 (1, 2, 3) {} +Check for issue #4806: Does a TypeError in a generator get propagated with the +right error message? (Also check with other iterables.) + + >>> def broken(): raise TypeError("myerror") + ... + + >>> g(*(broken() for i in range(1))) + Traceback (most recent call last): + ... + TypeError: myerror + + >>> class BrokenIterable1: + ... def __iter__(self): + ... raise TypeError('myerror') + ... + >>> g(*BrokenIterable1()) + Traceback (most recent call last): + ... + TypeError: myerror + + >>> class BrokenIterable2: + ... def __iter__(self): + ... yield 0 + ... raise TypeError('myerror') + ... + >>> g(*BrokenIterable2()) + Traceback (most recent call last): + ... + TypeError: myerror + + >>> class BrokenSequence: + ... def __getitem__(self, idx): + ... raise TypeError('myerror') + ... + >>> g(*BrokenSequence()) + Traceback (most recent call last): + ... + TypeError: myerror + Make sure that the function doesn't stomp the dictionary >>> d = {'a': 1, 'b': 2, 'c': 3} @@ -188,17 +227,17 @@ What about willful misconduct? >>> h(*h) Traceback (most recent call last): ... - TypeError: h() argument after * must be a sequence, not function + TypeError: h() argument after * must be an iterable, not function >>> dir(*h) Traceback (most recent call last): ... - TypeError: dir() argument after * must be a sequence, not function + TypeError: dir() argument after * must be an iterable, not function >>> None(*h) Traceback (most recent call last): ... - TypeError: NoneType object argument after * must be a sequence, \ + TypeError: NoneType object argument after * must be an iterable, \ not function >>> h(**h) |
