[Python-checkins] bpo-45379: add custom error string for FROZEN_DISABLED (GH-29190)
ambv
webhook-mailer at python.org
Thu Oct 28 16:20:15 EDT 2021
https://github.com/python/cpython/commit/233841ab782953510ad308dc6173072a6cc6a1cd
commit: 233841ab782953510ad308dc6173072a6cc6a1cd
branch: main
author: Filipe Laíns <lains at riseup.net>
committer: ambv <lukasz at langa.pl>
date: 2021-10-28T22:20:07+02:00
summary:
bpo-45379: add custom error string for FROZEN_DISABLED (GH-29190)
Signed-off-by: Filipe Laíns <lains at riseup.net>
Co-authored-by: Gareth Rees <gdr at garethrees.org>
files:
A Misc/NEWS.d/next/Core and Builtins/2021-10-23-13-49-00.bpo-45379.ZF7G3n.rst
M Python/import.c
diff --git a/Misc/NEWS.d/next/Core and Builtins/2021-10-23-13-49-00.bpo-45379.ZF7G3n.rst b/Misc/NEWS.d/next/Core and Builtins/2021-10-23-13-49-00.bpo-45379.ZF7G3n.rst
new file mode 100644
index 0000000000000..f8e2e50dfc3e2
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and Builtins/2021-10-23-13-49-00.bpo-45379.ZF7G3n.rst
@@ -0,0 +1,2 @@
+Clarify :exc:`ImportError` message when we try to explicitly import a
+frozen module but frozen modules are disabled.
diff --git a/Python/import.c b/Python/import.c
index fe4686cd56b3b..15b1956c102df 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -1153,9 +1153,11 @@ set_frozen_error(frozen_status status, PyObject *modname)
switch (status) {
case FROZEN_BAD_NAME:
case FROZEN_NOT_FOUND:
- case FROZEN_DISABLED:
err = "No such frozen object named %R";
break;
+ case FROZEN_DISABLED:
+ err = "Frozen modules are disabled and the frozen object named %R is not essential";
+ break;
case FROZEN_EXCLUDED:
err = "Excluded frozen object named %R";
break;
More information about the Python-checkins
mailing list