Skip to content
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-40334: Improvements to error-handling code in the PEG parser #20003

Merged
merged 5 commits into from
May 17, 2020

Conversation

lysnikolaou
Copy link
Member

@lysnikolaou lysnikolaou commented May 8, 2020

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

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
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.
@lysnikolaou
Copy link
Member Author

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

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

pablogsal commented May 11, 2020

  • 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?

@lysnikolaou
Copy link
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?

@pablogsal
Copy link
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
Copy link
Member Author

lysnikolaou commented May 17, 2020

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

Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
@pablogsal
Copy link
Member

@lysnikolaou You need to regenerate the parser 😉

@lysnikolaou
Copy link
Member Author

lysnikolaou commented May 17, 2020

@lysnikolaou You need to regenerate the parser 😉

Done! Sorry, it's getting late..

@pablogsal
Copy link
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 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 lysnikolaou deleted the error-improvements branch May 27, 2020 00:28
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.

None yet

4 participants