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 — [3.12] gh-111609: `end_offset` is ignored in subclasses of SyntaxError by nineteendo · Pull Request #127554 · python/cpython

Conversation

@nineteendo

@nineteendo nineteendo commented Dec 3, 2024 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

Example:

class CustomSyntaxError(SyntaxError):
    pass

raise CustomSyntaxError("Error message", (None, 1, 5, 'a = sin(3)', 1, 9))

main:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<string>", line 1
    a = sin(3)
        ^
CustomSyntaxError: Error message

PR:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<string>", line 1
    a = sin(3)
        ^^^^
CustomSyntaxError: Error message
  • Issue: end_offset is ignored in subclasses of SyntaxError (3.12-only) #111609

Sorry, something went wrong.

Uh oh!

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

All reactions
@nineteendo
end_offset is ignored in subclasses of SyntaxError
eb6aa27
@bedevere-app bedevere-app Bot mentioned this pull request Dec 3, 2024
end_offset is ignored in subclasses of SyntaxError (3.12-only) #111609
Closed
blurb-it Bot and others added 2 commits December 3, 2024 12:17
@blurb-it
📜🤖 Added by blurb_it.
6f5ef28
@nineteendo
Add test
204cd8d
@nineteendo
nineteendo marked this pull request as ready for review December 3, 2024 12:41
@nineteendo
nineteendo requested a review from iritkatriel as a code owner December 3, 2024 12:41
@bedevere-app bedevere-app Bot added the awaiting review label Dec 3, 2024
@nineteendo

nineteendo commented Dec 3, 2024 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor Author

@pablogsal, do you remember why this check was added in #25525? This works fine:

>>> class CustomSyntaxError(SyntaxError):
...     def __init__(self, msg, filename, lineno, offset, text, end_lineno, end_offset):
...         self.msg = msg
...         self.filename = filename
...         self.lineno = lineno
...         self.offset = offset
...         self.text = text
...         # self.end_lineno = end_lineno
...         # self.end_offset = end_offset
... 
>>> raise CustomSyntaxError("Error message", None, 1, 5, 'a = sin(3)', 1, 9)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<string>", line 1
    a = sin(3)
        ^
CustomSyntaxError: Error message
All reactions

Sorry, something went wrong.

Uh oh!

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

@pablogsal

pablogsal commented Dec 11, 2024 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

do you remember why this check was added in

What check are you referring to? The subclass check? IIRC is because some people were using some subclasses of syntax errors that were yielding weird results when displayed but I searched for the conversation and could not find anything :S

All reactions

Sorry, something went wrong.

Uh oh!

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

pablogsal
pablogsal reviewed Dec 11, 2024
View reviewed changes
Comment thread Lib/test/test_exceptions.py
self.assertIn(expected, err.getvalue())
the_exception = exc

def test_subclass(self):

@pablogsal pablogsal Dec 11, 2024

Copy link
Copy Markdown
Member

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.

Can we also add this test to main if is not there already?

Sorry, something went wrong.

Uh oh!

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

All reactions

@nineteendo nineteendo Dec 11, 2024

Copy link
Copy Markdown
Contributor 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 created a PR: #127830

Sorry, something went wrong.

Uh oh!

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

All reactions
pablogsal
pablogsal approved these changes Dec 11, 2024
View reviewed changes

@pablogsal pablogsal left a comment

Copy link
Copy Markdown
Member

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.

LGTM

Thanks for the catch @nineteendo!

Sorry, something went wrong.

Uh oh!

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

All reactions
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting review labels Dec 11, 2024
@pablogsal
pablogsal enabled auto-merge (squash) December 11, 2024 09:09
@pablogsal
pablogsal merged commit 487a51a into python:3.12 Dec 11, 2024
@bedevere-app bedevere-app Bot removed the awaiting merge label Dec 11, 2024
@nineteendo
nineteendo deleted the syntaxerr-subclass branch December 11, 2024 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@pablogsal pablogsal pablogsal approved these changes
@iritkatriel iritkatriel Awaiting requested review from iritkatriel iritkatriel is a code owner

Uh oh!

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

Assignees

No one assigned

Labels

None yet

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.

2 participants

@nineteendo @pablogsal
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 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.