aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/code.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/code.py')
-rw-r--r--Lib/code.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/Lib/code.py b/Lib/code.py
index c7c59ee2021..1cc2ed8b1db 100644
--- a/Lib/code.py
+++ b/Lib/code.py
@@ -136,7 +136,8 @@ class InteractiveInterpreter:
# Set the line of text that the exception refers to
lines = source.splitlines()
if (source and typ is SyntaxError
- and not value.text and len(lines) >= value.lineno):
+ and not value.text and value.lineno is not None
+ and len(lines) >= value.lineno):
value.text = lines[value.lineno - 1]
sys.last_exc = sys.last_value = value
if sys.excepthook is sys.__excepthook__: