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 — gh-123969: refactor _PyErr_RaiseSyntaxError and _PyErr_EmitSyntaxWarning out of compiler by iritkatriel · Pull Request #123972 · python/cpython

Conversation

@iritkatriel

@iritkatriel iritkatriel commented Sep 11, 2024 •
edited by bedevere-app Bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

These were local to the compiler, but after the splitting it would be good to be able to use them without needing to pass in a compiler struct (which is only used for the filename).

Fixes #123969.

  • Issue: Add _PyErr_RaiseSyntaxError and _PyErr_EmitSyntaxWarning #123969

Sorry, something went wrong.

Uh oh!

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

All reactions
@iritkatriel
pythongh-123969: refactor _PyErr_RaiseSyntaxError and _PyErr_EmitSynt…
b3deb0f
…axWarning out of compiler
@iritkatriel
iritkatriel requested a review from markshannon as a code owner September 11, 2024 19:24
@bedevere-app bedevere-app Bot added the awaiting core review label Sep 11, 2024
@bedevere-app bedevere-app Bot mentioned this pull request Sep 11, 2024
Add _PyErr_RaiseSyntaxError and _PyErr_EmitSyntaxWarning #123969
Closed
@iritkatriel iritkatriel added skip news interpreter-core (Objects, Python, Grammar, and Parser dirs) labels Sep 11, 2024
@iritkatriel
iritkatriel requested a review from JelleZijlstra September 11, 2024 19:39
iritkatriel
iritkatriel commented Sep 11, 2024
View reviewed changes
Comment thread Python/compile.c Resolved

Uh oh!

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

ZeroIntensity
ZeroIntensity reviewed Sep 11, 2024
View reviewed changes
Comment thread Python/errors.c Resolved

Uh oh!

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

@iritkatriel @ZeroIntensity
whitespace
6c0d57b
Co-authored-by: Peter Bierma <[email protected]>
serhiy-storchaka
serhiy-storchaka reviewed Sep 13, 2024
View reviewed changes
Comment thread Python/errors.c Resolved

Uh oh!

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

Comment thread Python/errors.c Resolved

Uh oh!

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

Comment thread Python/errors.c Resolved

Uh oh!

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

Comment thread Python/errors.c Resolved

Uh oh!

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

@iritkatriel
review comments
8523c1b
iritkatriel
iritkatriel commented Sep 13, 2024
View reviewed changes
Comment thread Python/errors.c Resolved

Uh oh!

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

@iritkatriel
Py_NewRef
4a007f4
@iritkatriel
iritkatriel requested a review from vstinner September 13, 2024 16:05
@vstinner vstinner mentioned this pull request Sep 13, 2024
[C API] Add _Py_NewImmortalRef() function to the internal C API #124074
Closed
JelleZijlstra
JelleZijlstra approved these changes Sep 16, 2024
View reviewed changes

@JelleZijlstra JelleZijlstra 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.

This change by itself feels unnecessary, but I'm guessing you'll use these functions in more places in the future. Would it make sense to change some of those other places in this PR so you can know whether the API will work for all cases.

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 core review labels Sep 16, 2024
vstinner
vstinner reviewed Sep 16, 2024
View reviewed changes
Comment thread Python/errors.c Resolved

Uh oh!

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

serhiy-storchaka
serhiy-storchaka approved these changes Sep 16, 2024
View reviewed changes

@serhiy-storchaka serhiy-storchaka 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.

Sorry, something went wrong.

Uh oh!

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

All reactions
@iritkatriel
increment cols in caller
763b250
vstinner
vstinner reviewed Sep 16, 2024
View reviewed changes
Comment thread Python/errors.c Outdated
text = Py_NewRef(Py_None);
}
PyObject *args = Py_BuildValue("O(OiiOii)", msg, filename,
lineno, col_offset + 1, text,

@vstinner vstinner Sep 16, 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.

You still do the +1 here, so at the end, it's +2 which is wrong, no?

Sorry, something went wrong.

Uh oh!

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

All reactions
@iritkatriel

iritkatriel commented Sep 16, 2024

Copy link
Copy Markdown
Member Author

This change by itself feels unnecessary, but I'm guessing you'll use these functions in more places in the future. Would it make sense to change some of those other places in this PR so you can know whether the API will work for all cases.

I want to use it in order to raise the assert(tuple) warning from ast_opt (and move the assert optimization there). It felt like putting it in the PR would lump together two different things, but I could do it that way.

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

Sorry, something went wrong.

Uh oh!

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

@iritkatriel
Merge branch 'main' into syntax-error
167a67c
@vstinner

vstinner commented Sep 16, 2024

Copy link
Copy Markdown
Member

I prefer a separated PR just for these two PyErr functions.

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

Sorry, something went wrong.

Uh oh!

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

iritkatriel added 2 commits September 16, 2024 14:21
@iritkatriel
increment cols in caller
d568737
@iritkatriel
increment cols in caller - one more place
c679776
vstinner
vstinner approved these changes Sep 16, 2024
View reviewed changes

@vstinner vstinner 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.

Is the +1 on col_offset needed because compile.c counts starting at 0 and the displayed error starts counting at 1?

Sorry, something went wrong.

Uh oh!

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

All reactions
@iritkatriel

iritkatriel commented Sep 16, 2024

Copy link
Copy Markdown
Member Author

LGTM.

Is the +1 on col_offset needed because compile.c counts starting at 0 and the displayed error starts counting at 1?

SyntaxError is defined to start at 1: https://docs.python.org/3/library/exceptions.html#SyntaxError

All reactions

Sorry, something went wrong.

Uh oh!

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

@iritkatriel

iritkatriel commented Sep 16, 2024

Copy link
Copy Markdown
Member Author

LGTM.
Is the +1 on col_offset needed because compile.c counts starting at 0 and the displayed error starts counting at 1?

SyntaxError is defined to start at 1: https://docs.python.org/3/library/exceptions.html#SyntaxError

The location comes from the AST, where it starts at 0.

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

Sorry, something went wrong.

Uh oh!

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

@iritkatriel
iritkatriel merged commit aba42c0 into python:main Sep 16, 2024
@bedevere-app bedevere-app Bot removed the awaiting merge label Sep 16, 2024
savannahostrowski pushed a commit to savannahostrowski/cpython that referenced this pull request Sep 22, 2024
@iritkatriel @savannahostrowski
pythongh-123969: refactor _PyErr_RaiseSyntaxError and _PyErr_EmitSynt…
66a9161
…axWarning out of compiler (python#123972)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@serhiy-storchaka serhiy-storchaka serhiy-storchaka approved these changes
@ZeroIntensity ZeroIntensity ZeroIntensity left review comments
@vstinner vstinner vstinner approved these changes
@JelleZijlstra JelleZijlstra JelleZijlstra approved these changes
@markshannon markshannon Awaiting requested review from markshannon markshannon is a code owner

Uh oh!

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

Assignees

No one assigned

Labels

interpreter-core (Objects, Python, Grammar, and Parser dirs) skip news

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Add _PyErr_RaiseSyntaxError and _PyErr_EmitSyntaxWarning

Uh oh!

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

5 participants

@iritkatriel @vstinner @JelleZijlstra @serhiy-storchaka @ZeroIntensity
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.