New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bpo-34463: Match python traceback format to the C traceback for a Syn… #23427
Conversation
…taxError without lineno.
This PR is stale because it has been open for 30 days with no activity. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one minor comment.
Also, this may be a good opportunity to convert this code to use f-strings; ISTM it would make it slightly clearer.
Lib/traceback.py
Outdated
filename = self.filename or "<string>" | ||
lineno = str(self.lineno) or '?' | ||
yield ' File "{}", line {}\n'.format(filename, lineno) | ||
filename_suffix = '' | ||
if self.lineno is not None: | ||
yield ' File "{}", line {}\n'.format(filename, self.lineno) | ||
elif self.filename is not None: | ||
filename_suffix = ' ({})'.format(self.filename) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since filename
is only used in the first "if" block, but self.filename
is used later, I'd move its definition into the block, or just remove it and use self.filename or "<string>"
inline.
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
Indeed. I have made the requested changes; please review again. |
Thanks for making the requested changes! @taleinat: please review the changes made to this pull request. |
Thanks @iritkatriel for the PR, and @taleinat for merging it 🌮🎉.. I'm working now to backport this PR to: 3.8, 3.9. |
…xErrors without a lineno (pythonGH-23427) (cherry picked from commit 069560b) Co-authored-by: Irit Katriel <iritkatriel@yahoo.com>
GH-23895 is a backport of this pull request to the 3.9 branch. |
Sorry, @iritkatriel and @taleinat, I could not cleanly backport this to |
@taleinat Thanks, I'll sort out the backport to 3.8 |
SyntaxErrors without a lineno (pythonGH-23427) (cherry picked from commit 069560b) Co-authored-by: Irit Katriel <iritkatriel@yahoo.com>
…xErrors without a lineno (pythonGH-23427)
…#23899) * [3.8] bpo-34463: Make python tracebacks identical to C tracebacks for SyntaxErrors without a lineno (GH-23427) (cherry picked from commit 069560b) Co-authored-by: Irit Katriel <iritkatriel@yahoo.com> * 📜🤖 Added by blurb_it. * added missing newline in test Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
…taxError without lineno.
https://bugs.python.org/issue34463