]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-46522: fix concurrent.futures and io AttributeError messages (GH-30887)
authorThomas Grainger <tagrain@gmail.com>
Wed, 23 Feb 2022 00:25:00 +0000 (00:25 +0000)
committerGitHub <noreply@github.com>
Wed, 23 Feb 2022 00:25:00 +0000 (02:25 +0200)
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
Lib/_pyio.py
Lib/concurrent/futures/__init__.py
Lib/io.py
Misc/NEWS.d/next/Library/2022-01-25-15-31-04.bpo-46522.tYAlX4.rst [new file with mode: 0644]

index d7119742b9d22b1f5459bf0dd64bdf251f350d89..8f20c5ed2abd5c8bb1c25734fd9da862dd87d270 100644 (file)
@@ -312,7 +312,7 @@ def __getattr__(name):
         global OpenWrapper
         OpenWrapper = open
         return OpenWrapper
-    raise AttributeError(name)
+    raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
 
 
 # In normal operation, both `UnsupportedOperation`s should be bound to the
index d746aeac50a99763ecce100d17c75fbca123a19d..292e886d5a88ac90b41f998702c5dbf11e44ce9b 100644 (file)
@@ -50,4 +50,4 @@ def __getattr__(name):
         ThreadPoolExecutor = te
         return te
 
-    raise AttributeError(f"module {__name__} has no attribute {name}")
+    raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
index 2a6140c3dd50940f771268aafc20fe40efa01302..a205e00575f7e87df830a88c78189d8075977bad 100644 (file)
--- a/Lib/io.py
+++ b/Lib/io.py
@@ -70,7 +70,7 @@ def __getattr__(name):
         global OpenWrapper
         OpenWrapper = open
         return OpenWrapper
-    raise AttributeError(name)
+    raise AttributeError("module {__name__!r} has no attribute {name!r}")
 
 
 # Pretend this exception was created here.
diff --git a/Misc/NEWS.d/next/Library/2022-01-25-15-31-04.bpo-46522.tYAlX4.rst b/Misc/NEWS.d/next/Library/2022-01-25-15-31-04.bpo-46522.tYAlX4.rst
new file mode 100644 (file)
index 0000000..999863a
--- /dev/null
@@ -0,0 +1 @@
+Make various module ``__getattr__`` AttributeErrors more closely match a typical AttributeError