Repository navigation
Conversation
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
|
I think that this fix doesn't require a NEWS entry. But I am opened to suggestions |
|
We need a news entry can you add one please? |
|
Yes, sure. Thanks for the review |
|
Seems that the CI error is not related to the PR itself. |
|
I retried it |
Looks like it is a github issue? The run itself doesnt get to the building stage |
|
Thank you for the CI rerun. All of the tests have passed |
|
Could you, please, review this PR if you have time @lysnikolaou? |
|
Sorry for a late response @StanFromIreland |
|
Worth considering if this would be neater? If we assume that parse failure paths always return NULL, then you can diff --git a/Tools/peg_generator/pegen/c_generator.py b/Tools/peg_generator/pegen/c_generator.py
index d9236dfb22835bd..bb0cc34c68a75e9 100644
--- a/Tools/peg_generator/pegen/c_generator.py
+++ b/Tools/peg_generator/pegen/c_generator.py
@@ -658,10 +658,12 @@ def _handle_loop_rule_body(self, node: Rule, rhs: Rhs) -> None:
)
if is_repeat1:
self.print("if (_n == 0 || p->error_indicator) {")
- with self.indent():
- self.print("PyMem_Free(_children);")
- self.add_return("NULL")
- self.print("}")
+ else:
+ self.print("if (p->error_indicator) {")
+ with self.indent():
+ self.print("PyMem_Free(_children);")
+ self.add_return("NULL")
+ self.print("}")
self.print("asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena);")
self.out_of_memory_return("!_seq", cleanup_code="PyMem_Free(_children);")
self.print("for (Py_ssize_t i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]);")This way we have one check shared between loop0 and loop1 without duplicating it on the loop1? BTW: this code is new to me, so I probably made some assumptions here! |
|
I think we can merge this ver and then reiterate with a follow up? |
|
Can you please fix the conflicts? |
Sure, working on it now |
Added a regression test as well (with the string generated by fuzzer in the issue).
MemoryErrorduring parse can escalate toSystemErrorand abort on small input #150001