File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -94,6 +94,24 @@ Improved Error Messages
9494 variables. See also :ref: `using-on-controlling-color `.
9595 (Contributed by Pablo Galindo Salgado in :gh: `112730 `.)
9696
97+ * A common mistake is to write a script with the same name as a
98+ standard library module. The interpreter now detects this and
99+ displays a more helpful error message.
100+ (Contributed by Shantanu Jain in :gh: `95754 `.)
101+
102+ .. code-block :: shell-session
103+
104+ $ python random.py
105+ Traceback (most recent call last):
106+ File "/home/random.py", line 1, in <module>
107+ import random; print(random.randint(5))
108+ ^^^^^^^^^^^^^
109+ File "/home/random.py", line 1, in <module>
110+ import random; print(random.randint(5))
111+ ^^^^^^^^^^^^^^
112+ AttributeError: module 'random' has no attribute 'randint' (most likely due to '/home/random.py' shadowing the standard library module named 'random')
113+
114+
97115 Other Language Changes
98116======================
99117
You can’t perform that action at this time.
0 commit comments