GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix #591 changing stack trace linenos · MarkTseng/bpython@4e5db7c

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • bpython
    • repl.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎bpython/repl.py‎

Copy file name to clipboardExpand all lines: bpython/repl.py
+12-3Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import os
3030
import pkgutil
3131
import pydoc
32+
import re
3233
import shlex
3334
import subprocess
3435
import sys
@@ -133,6 +134,9 @@ def showsyntaxerror(self, filename=None):
133134
# Stuff in the right filename and right lineno
134135
if not py3:
135136
lineno -= 1
137+
if re.match(r'<bpython-input-\d+>', filename):
138+
filename = '<input>'
139+
# strip linecache line number
136140
value = SyntaxError(msg, (filename, lineno, offset, line))
137141
sys.last_value = value
138142
list = traceback.format_exception_only(type, value)
@@ -149,9 +153,14 @@ def showtraceback(self):
149153
sys.last_traceback = tb
150154
tblist = traceback.extract_tb(tb)
151155
del tblist[:1]
152-
# Set the right lineno (encoding header adds an extra line)
153-
if not py3:
154-
for i, (fname, lineno, module, something) in enumerate(tblist):
156+
157+
for i, (fname, lineno, module, something) in enumerate(tblist):
158+
# strip linecache line number
159+
if re.match(r'<bpython-input-\d+>', fname):
160+
fname = '<input>'
161+
tblist[i] = (fname, lineno, module, something)
162+
# Set the right lineno (encoding header adds an extra line)
163+
if not py3:
155164
if fname == '<input>':
156165
tblist[i] = (fname, lineno - 1, module, something)
157166

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.