← 返回首页
bpo-40334: Improvements to error-handling code in the PEG parser by lysnikolaou · Pull Request #20003 · python/cpython · GitHub
Skip to content

Navigation Menu

Toggle navigation
Sign in
Appearance settings
Search or jump to...

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Resetting focus

bpo-40334: Improvements to error-handling code in the PEG parser#20003

Merged
pablogsal merged 5 commits into
python:masterfrom
lysnikolaou:error-improvements
May 17, 2020
Merged

bpo-40334: Improvements to error-handling code in the PEG parser#20003
pablogsal merged 5 commits into
python:masterfrom
lysnikolaou:error-improvements

Conversation

lysnikolaou commented May 8, 2020
edited by bedevere-bot
Loading

Copy link
Copy Markdown
Member

Following improvements are implemented in this PR:

  • p->error_indicator is set, in case malloc or realloc fail
  • Avoid memory leaks in the case that realloc fails
  • Call PyErr_NoMemory() instead of PyErr_Format(), because it
    requires no memory

https://bugs.python.org/issue40334

Following improvements are implemented in this PR: - `p->error_indicator` is set, in case malloc or realloc fail - Avoid memory leaks in the case that realloc fails - Call `PyErr_NoMemory()` instead of `PyErr_Format()`, because it requires no memory.

Copy link
Copy Markdown
Member Author

Note to self: This partially conflicts with #19987, so will probably need to merge master after that's landed.

lysnikolaou requested review from gvanrossum and pablogsal and removed request for gvanrossum and pablogsal May 11, 2020 15:22

pablogsal commented May 11, 2020
edited
Loading

Copy link
Copy Markdown
Member
  • p->error_indicator is set, in case malloc or realloc fail

Do we need to do this? As soon as the rule returns it will go immediately to a if (_res == NULL && PyErr_Occurred()) block, no?

Copy link
Copy Markdown
Member Author
  • p->error_indicator is set, in case malloc or realloc fail

Do we need to do this? As soon as the rule returns it will go immediately to a if (_res == NULL && PyErr_Occurred()) block, no?

I can't really see this, how exactly is this?

Copy link
Copy Markdown
Member

I can't really see this, how exactly is this?

I have checked again and this only happens when the rule does not return NULL, so forget what I said :(

lysnikolaou commented May 17, 2020
edited by bedevere-bot
Loading

Copy link
Copy Markdown
Member Author

Resolved the conflicts so that we can hopefully merge this and close bpo-40334.

Comment thread Tools/peg_generator/pegen/c_generator.py Outdated Show resolved Hide resolved
Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>

Copy link
Copy Markdown
Member

@lysnikolaou You need to regenerate the parser 😉

lysnikolaou commented May 17, 2020
edited
Loading

Copy link
Copy Markdown
Member Author

@lysnikolaou You need to regenerate the parser 😉

Done! Sorry, it's getting late..

Copy link
Copy Markdown
Member

Done! Sorry, it's getting late..

No problem. I want to land this and the other PR so they both make it to beta 1 which is next Monday :)

pablogsal merged commit 2c8cd06 into python:master May 17, 2020
arturoescaip pushed a commit to arturoescaip/cpython that referenced this pull request May 24, 2020
…honGH-20003) The following improvements are implemented in this commit: - `p->error_indicator` is set, in case malloc or realloc fail. - Avoid memory leaks in the case that realloc fails. - Call `PyErr_NoMemory()` instead of `PyErr_Format()`, because it requires no memory. Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
lysnikolaou deleted the error-improvements branch May 27, 2020 00:28
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

Footer

© 2026 GitHub, Inc.