From f69e0b5128480a7d4ca1e7f4b873a00f1b8358b8 Mon Sep 17 00:00:00 2001 From: hauntsaninja Date: Sat, 6 Jan 2024 01:58:51 -0800 Subject: [PATCH] Add What's New --- Doc/whatsnew/3.13.rst | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Doc/whatsnew/3.13.rst b/Doc/whatsnew/3.13.rst index 3ab6d1ddc6ef213..622741202a4d0ce 100644 --- a/Doc/whatsnew/3.13.rst +++ b/Doc/whatsnew/3.13.rst @@ -94,6 +94,24 @@ Improved Error Messages variables. See also :ref:`using-on-controlling-color`. (Contributed by Pablo Galindo Salgado in :gh:`112730`.) +* A common mistake is to write a script with the same name as a + standard library module. The interpreter now detects this and + displays a more helpful error message. + (Contributed by Shantanu Jain in :gh:`95754`.) + + .. code-block:: shell-session + + $ python random.py + Traceback (most recent call last): + File "/home/random.py", line 1, in + import random; print(random.randint(5)) + ^^^^^^^^^^^^^ + File "/home/random.py", line 1, in + import random; print(random.randint(5)) + ^^^^^^^^^^^^^^ + AttributeError: module 'random' has no attribute 'randint' (most likely due to '/home/random.py' shadowing the standard library module named 'random') + + Other Language Changes ======================