Skip to content

Commit 6a5f7d5

Browse files
author
Andres
committed
Fmt/lint
1 parent 22ed965 commit 6a5f7d5

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Fixed a :exc:`SystemError` in :func:`__lazy_import__` caused by passing
2+
invalid argument types. Added proper type validation for *name*, *globals*,
3+
*locals*, and *fromlist* arguments.

Misc/mypy/_colorize.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
../../Lib/_colorize.py
1+
../../Lib/_colorize.py

Misc/mypy/token.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
../../Lib/token.py
1+
../../Lib/token.py

Python/bltinmodule.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -314,29 +314,29 @@ builtin___lazy_import___impl(PyObject *module, PyObject *name,
314314

315315
// Validate input arguments
316316
if (!PyUnicode_Check(name)) {
317-
PyErr_Format(PyExc_TypeError,
317+
PyErr_Format(PyExc_TypeError,
318318
"__lazy_import__() argument 1 must be str, not %.200s",
319319
Py_TYPE(name)->tp_name);
320320
return NULL;
321321
}
322322

323323
if (globals != NULL && !PyDict_Check(globals)) {
324-
PyErr_Format(PyExc_TypeError,
324+
PyErr_Format(PyExc_TypeError,
325325
"__lazy_import__() argument 2 must be dict, not %.200s",
326326
Py_TYPE(globals)->tp_name);
327327
return NULL;
328328
}
329329

330330
if (locals != NULL && !PyDict_Check(locals)) {
331-
PyErr_Format(PyExc_TypeError,
331+
PyErr_Format(PyExc_TypeError,
332332
"__lazy_import__() argument 3 must be dict, not %.200s",
333333
Py_TYPE(locals)->tp_name);
334334
return NULL;
335335
}
336336

337-
if (fromlist != NULL && fromlist != Py_None &&
337+
if (fromlist != NULL && fromlist != Py_None &&
338338
!PyList_Check(fromlist) && !PyTuple_Check(fromlist)) {
339-
PyErr_Format(PyExc_TypeError,
339+
PyErr_Format(PyExc_TypeError,
340340
"__lazy_import__() argument 4 must be a list or tuple, not %.200s",
341341
Py_TYPE(fromlist)->tp_name);
342342
return NULL;

0 commit comments

Comments
 (0)