Skip to content

Commit 467f803

Browse files
committed
Update error messages
1 parent 9440f8f commit 467f803

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

Python/_warnings.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,8 +1271,9 @@ warnings_warn_explicit_impl(PyObject *module, PyObject *message,
12711271
if (module_globals && module_globals != Py_None) {
12721272
if (!PyAnyDict_Check(module_globals)) {
12731273
PyErr_Format(PyExc_TypeError,
1274-
"module_globals must be a dict, not '%.200s'",
1275-
Py_TYPE(module_globals)->tp_name);
1274+
"module_globals must be a dict or a frozendict, "
1275+
"not %T",
1276+
module_globals);
12761277
return NULL;
12771278
}
12781279

Python/import.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3729,7 +3729,8 @@ resolve_name(PyThreadState *tstate, PyObject *name, PyObject *globals, int level
37293729
goto error;
37303730
}
37313731
if (!PyAnyDict_Check(globals)) {
3732-
_PyErr_SetString(tstate, PyExc_TypeError, "globals must be a dict");
3732+
_PyErr_SetString(tstate, PyExc_TypeError,
3733+
"globals must be a dict or a frozendict");
37333734
goto error;
37343735
}
37353736
if (PyDict_GetItemRef(globals, &_Py_ID(__package__), &package) < 0) {

Python/pythonrun.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1348,7 +1348,8 @@ run_eval_code_obj(PyThreadState *tstate, PyCodeObject *co, PyObject *globals, Py
13481348
{
13491349
/* Set globals['__builtins__'] if it doesn't exist */
13501350
if (!globals || !PyAnyDict_Check(globals)) {
1351-
PyErr_SetString(PyExc_SystemError, "globals must be a real dict");
1351+
PyErr_SetString(PyExc_SystemError,
1352+
"globals must be a real dict or a real frozendict");
13521353
return NULL;
13531354
}
13541355
int has_builtins = PyDict_ContainsString(globals, "__builtins__");

0 commit comments

Comments
 (0)