@@ -2113,30 +2113,30 @@ def printsolution(self, x):
2113
2113
>>> g.throw(ValueError("xyz")) # value only
2114
2114
caught ValueError (xyz)
2115
2115
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
-
2122
2116
>>> 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.
2124
2120
2125
2121
>>> 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.
2127
2125
2128
2126
>>> 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.
2130
2130
2131
2131
>>> g.throw(ValueError(1), "foo") # bad args
2132
2132
Traceback (most recent call last):
2133
2133
...
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.
2135
2135
2136
2136
>>> g.throw(ValueError, "foo", 23) # bad args
2137
2137
Traceback (most recent call last):
2138
2138
...
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.
2140
2140
2141
2141
>>> g.throw("abc")
2142
2142
Traceback (most recent call last):
@@ -2159,39 +2159,27 @@ def printsolution(self, x):
2159
2159
... except:
2160
2160
... g.throw(*sys.exc_info())
2161
2161
>>> 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.
2163
2165
2164
2166
>>> g.send(1)
2165
2167
1
2166
2168
2167
2169
>>> throw(g,TypeError) # terminate the generator
2168
2170
Traceback (most recent call last):
2169
2171
...
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.
2179
2173
2180
2174
>>> g.throw(ValueError,6) # throw on closed generator
2181
2175
Traceback (most recent call last):
2182
2176
...
2183
- ValueError: 6
2177
+ DeprecationWarning: the (type, exc, tb) signature of throw() is deprecated, use the single-arg signature instead.
2184
2178
2185
2179
>>> f().throw(ValueError,7) # throw on just-opened generator
2186
2180
Traceback (most recent call last):
2187
2181
...
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.
2195
2183
2196
2184
Plain "raise" inside a generator should preserve the traceback (#13188).
2197
2185
The traceback should have 3 levels:
0 commit comments