Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(17)

Unified Diff: Lib/test/test_extcall.py

Issue 4806: Function calls taking a generator as star argument can mask TypeErrors in the generator
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Misc/NEWS » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Lib/test/test_extcall.py Fri Jan 29 19:06:00 2016 -0600
+++ b/Lib/test/test_extcall.py Sun Jan 31 11:19:40 2016 +0000
@@ -93,7 +93,7 @@
>>> g(*Nothing())
Traceback (most recent call last):
...
- TypeError: g() argument after * must be a sequence, not instance
+ TypeError: g() argument after * must be an iterable, not instance
>>> class Nothing:
... def __len__(self): return 5
@@ -102,7 +102,7 @@
>>> g(*Nothing())
Traceback (most recent call last):
...
- TypeError: g() argument after * must be a sequence, not instance
+ TypeError: g() argument after * must be an iterable, not instance
>>> class Nothing():
... def __len__(self): return 5
@@ -128,6 +128,17 @@
>>> g(*Nothing())
0 (1, 2, 3) {}
+Check for issue #4806: Does a TypeError in a generator get propagated with the
+right error message?
+
+ >>> def broken(): raise TypeError("myerror")
+ ...
+
+ >>> g(*(broken() for i in range(1)))
+ Traceback (most recent call last):
+ ...
+ TypeError: myerror
+
Make sure that the function doesn't stomp the dictionary
>>> d = {'a': 1, 'b': 2, 'c': 3}
@@ -167,17 +178,17 @@
>>> 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)
« no previous file with comments | « no previous file | Misc/NEWS » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+