File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed
Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -3511,6 +3511,15 @@ def test_lazy_import_in_trystar_block(self):
35113511 pass
35123512""" , "lazy from ... import not allowed inside try/except blocks" )
35133513
3514+ def test_lazy_import_in_except_block (self ):
3515+ """Test that lazy imports are not allowed inside except blocks."""
3516+ self ._check_error ("""\
3517+ try:
3518+ sys.modules # trigger the except block
3519+ except* Exception:
3520+ lazy import sys
3521+ """ , "lazy import not allowed inside try/except blocks" )
3522+
35143523 def test_lazy_import_in_function (self ):
35153524 """Test that lazy imports are not allowed inside functions."""
35163525 self ._check_error ("""\
Original file line number Diff line number Diff line change @@ -112,7 +112,6 @@ lazy_import_repr(PyObject *op)
112112static PyObject *
113113lazy_import_new (PyTypeObject * type , PyObject * args , PyObject * kwds )
114114{
115- PyTypeObject * base_tp = & PyLazyImport_Type ;
116115 if (!_PyArg_NoKeywords ("lazy_import" , kwds )) {
117116 return NULL ;
118117 }
You can’t perform that action at this time.
0 commit comments