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 — bpo-45249: Ensure the traceback module prints correctly syntax errors with ranges by pablogsal · Pull Request #28575 · python/cpython

Conversation

@pablogsal

@pablogsal pablogsal commented Sep 26, 2021 •
edited by bedevere-bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

https://bugs.python.org/issue45249

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@pablogsal pablogsal added the needs backport to 3.10 label Sep 26, 2021
@the-knights-who-say-ni the-knights-who-say-ni added the CLA signed label Sep 26, 2021
@bedevere-bot bedevere-bot added the awaiting core review label Sep 26, 2021
@pablogsal
bpo-45249: Ensure the traceback module prints correctly syntax errors…
16bf58a
… with ranges
@pablogsal
pablogsal force-pushed the bpo-45249 branch from a6e7698 to 16bf58a Compare September 27, 2021 00:41
@pablogsal pablogsal added the skip news label Sep 27, 2021
@pablogsal
pablogsal merged commit 20f439b into python:main Sep 27, 2021
@pablogsal
pablogsal deleted the bpo-45249 branch September 27, 2021 20:59
@miss-islington

miss-islington commented Sep 27, 2021

Copy link
Copy Markdown
Contributor

Thanks @pablogsal for the PR 🌮🎉.. I'm working now to backport this PR to: 3.10.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot bedevere-bot removed the awaiting core review label Sep 27, 2021
@bedevere-bot

bedevere-bot commented Sep 27, 2021

Copy link
Copy Markdown

GH-28587 is a backport of this pull request to the 3.10 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot bedevere-bot removed the needs backport to 3.10 label Sep 27, 2021
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Sep 27, 2021
@pablogsal @miss-islington
bpo-45249: Ensure the traceback module prints correctly syntax errors…
b8c7ed8
… with ranges (pythonGH-28575)

(cherry picked from commit 20f439b)

Co-authored-by: Pablo Galindo Salgado <[email protected]>
miss-islington added a commit that referenced this pull request Sep 27, 2021
@miss-islington @pablogsal
bpo-45249: Ensure the traceback module prints correctly syntax errors…
c7fdd68
… with ranges (GH-28575)

(cherry picked from commit 20f439b)

Co-authored-by: Pablo Galindo Salgado <[email protected]>
pablogsal added a commit that referenced this pull request Sep 29, 2021
@miss-islington @pablogsal
bpo-45249: Ensure the traceback module prints correctly syntax errors…
1e20582
… with ranges (GH-28575)

(cherry picked from commit 20f439b)

Co-authored-by: Pablo Galindo Salgado <[email protected]>
blueyed
blueyed reviewed Oct 10, 2021
View reviewed changes
Comment thread Lib/traceback.py
- :attr:`offset` For syntax errors - the offset into the text where the
error occurred.
- :attr:`end_offset` For syntax errors - the offset into the text where the
error occurred. Can be `None` if not present.

@blueyed blueyed Oct 10, 2021

Copy link
Copy Markdown
Contributor

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.

It is not None, but an unset attribute for non-SyntaxErrors, since it gets set for if exc_type and issubclass(exc_type, SyntaxError) only.
I think it should either get initialized always (to None), or at least the doc should get fixed (both places above).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@pablogsal pablogsal Oct 10, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

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.

I think it should either get initialized always (to None), or at least the doc should get fixed (both places above).

I disagree. The text is the same as for other syntax errors fields. It says:

attr:end_offset For syntax errors

the same way offset is also for syntax errors:

:attr:offset For syntax errors

The thing here is that end_offset can be None if not present even for syntax errors.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Lib/traceback.py
offset = self.offset
end_offset = self.end_offset if self.end_offset is not None else offset
if offset == end_offset or end_offset == -1:
end_offset = offset + 1

@blueyed blueyed Oct 10, 2021

Copy link
Copy Markdown
Contributor

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.

I've noticed that self.end_offset is 0 with https://bugs.python.org/msg403588 (https://bugs.python.org/issue45249).
This might boil down to / coming from the C code using -1 for "not given/used", and then 1 being added, and therefore 0 should also get handled as "no end offset provided, use a length of 1".

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

pablogsal reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

@pablogsal pablogsal Oct 10, 2021

Copy link
Copy Markdown
Member Author

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.

Addressed in #28855

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
This was referenced Apr 10, 2022
Update doctect SyntaxErrors for location range #89412
Closed
gh-89412: Add missing attributes (added in 3.10) to traceback module docs #105046
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

1 more reviewer
@blueyed blueyed blueyed left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

skip news

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@pablogsal @miss-islington @bedevere-bot @blueyed @the-knights-who-say-ni
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — 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.