@@ -2113,30 +2113,30 @@ def printsolution(self, x):
21132113>>> g.throw(ValueError("xyz")) # value only
21142114caught ValueError (xyz)
21152115
2116- >>> import warnings
2117- >>> warnings.filterwarnings("ignore", category=DeprecationWarning)
2118-
2119- # Filter DeprecationWarning: regarding the (type, val, tb) signature of throw().
2120- # Deprecation warnings are re-enabled below.
2121-
21222116>>> g.throw(ValueError, ValueError(1)) # value+matching type
2123- caught ValueError (1)
2117+ Traceback (most recent call last):
2118+ ...
2119+ DeprecationWarning: the (type, exc, tb) signature of throw() is deprecated, use the single-arg signature instead.
21242120
21252121>>> g.throw(ValueError, TypeError(1)) # mismatched type, rewrapped
2126- caught ValueError (1)
2122+ Traceback (most recent call last):
2123+ ...
2124+ DeprecationWarning: the (type, exc, tb) signature of throw() is deprecated, use the single-arg signature instead.
21272125
21282126>>> g.throw(ValueError, ValueError(1), None) # explicit None traceback
2129- caught ValueError (1)
2127+ Traceback (most recent call last):
2128+ ...
2129+ DeprecationWarning: the (type, exc, tb) signature of throw() is deprecated, use the single-arg signature instead.
21302130
21312131>>> g.throw(ValueError(1), "foo") # bad args
21322132Traceback (most recent call last):
21332133 ...
2134- TypeError: instance exception may not have a separate value
2134+ DeprecationWarning: the (type, exc, tb) signature of throw() is deprecated, use the single-arg signature instead.
21352135
21362136>>> g.throw(ValueError, "foo", 23) # bad args
21372137Traceback (most recent call last):
21382138 ...
2139- TypeError: throw() third argument must be a traceback object
2139+ DeprecationWarning: the (type, exc, tb) signature of throw() is deprecated, use the single-arg signature instead.
21402140
21412141>>> g.throw("abc")
21422142Traceback (most recent call last):
@@ -2159,39 +2159,27 @@ def printsolution(self, x):
21592159... except:
21602160... g.throw(*sys.exc_info())
21612161>>> throw(g,ValueError) # do it with traceback included
2162- caught ValueError ()
2162+ Traceback (most recent call last):
2163+ ...
2164+ DeprecationWarning: the (type, exc, tb) signature of throw() is deprecated, use the single-arg signature instead.
21632165
21642166>>> g.send(1)
216521671
21662168
21672169>>> throw(g,TypeError) # terminate the generator
21682170Traceback (most recent call last):
21692171 ...
2170- TypeError
2171-
2172- >>> print(g.gi_frame)
2173- None
2174-
2175- >>> g.send(2)
2176- Traceback (most recent call last):
2177- ...
2178- StopIteration
2172+ DeprecationWarning: the (type, exc, tb) signature of throw() is deprecated, use the single-arg signature instead.
21792173
21802174>>> g.throw(ValueError,6) # throw on closed generator
21812175Traceback (most recent call last):
21822176 ...
2183- ValueError: 6
2177+ DeprecationWarning: the (type, exc, tb) signature of throw() is deprecated, use the single-arg signature instead.
21842178
21852179>>> f().throw(ValueError,7) # throw on just-opened generator
21862180Traceback (most recent call last):
21872181 ...
2188- ValueError: 7
2189-
2190- >>> warnings.filters.pop(0)
2191- ('ignore', None, <class 'DeprecationWarning'>, None, 0)
2192-
2193- # Re-enable DeprecationWarning: the (type, val, tb) exception representation is deprecated,
2194- # and may be removed in a future version of Python.
2182+ DeprecationWarning: the (type, exc, tb) signature of throw() is deprecated, use the single-arg signature instead.
21952183
21962184Plain "raise" inside a generator should preserve the traceback (#13188).
21972185The traceback should have 3 levels:
0 commit comments