pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/python/cpython/commit/bd8c1f97e1709b5e8b07c31b1bc7b73acc76169d

97560d244c08.css" /> gh-94808: Reorganize _make_posargs and mark unused code (GH-119227) · python/cpython@bd8c1f9 · GitHub
Skip to content

Commit bd8c1f9

Browse files
authored
gh-94808: Reorganize _make_posargs and mark unused code (GH-119227)
* Reorganize four-way if-elsif-elsif-elsif as nested if-elses * Mark unused branch in _make_posargs `names_with_default` is never `NULL`, even if there are no names with defaults. In that case it points to a structure with `size` zero. Rather than eliminating the branch, we leave it behind with an `assert(0)` in case a future change to the grammar exercises the branch.
1 parent 99d945c commit bd8c1f9

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

Parser/action_helpers.c

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -543,22 +543,30 @@ _make_posargs(Parser *p,
543543
asdl_arg_seq *plain_names,
544544
asdl_seq *names_with_default,
545545
asdl_arg_seq **posargs) {
546-
if (plain_names != NULL && names_with_default != NULL) {
547-
asdl_arg_seq *names_with_default_names = _get_names(p, names_with_default);
548-
if (!names_with_default_names) {
549-
return -1;
546+
547+
if (names_with_default != NULL) {
548+
if (plain_names != NULL) {
549+
asdl_arg_seq *names_with_default_names = _get_names(p, names_with_default);
550+
if (!names_with_default_names) {
551+
return -1;
552+
}
553+
*posargs = (asdl_arg_seq*)_PyPegen_join_sequences(
554+
p,(asdl_seq*)plain_names, (asdl_seq*)names_with_default_names);
555+
}
556+
else {
557+
*posargs = _get_names(p, names_with_default);
550558
}
551-
*posargs = (asdl_arg_seq*)_PyPegen_join_sequences(
552-
p,(asdl_seq*)plain_names, (asdl_seq*)names_with_default_names);
553-
}
554-
else if (plain_names == NULL && names_with_default != NULL) {
555-
*posargs = _get_names(p, names_with_default);
556-
}
557-
else if (plain_names != NULL && names_with_default == NULL) {
558-
*posargs = plain_names;
559559
}
560560
else {
561-
*posargs = _Py_asdl_arg_seq_new(0, p->arena);
561+
if (plain_names != NULL) {
562+
// With the current grammar, we never get here.
563+
// If that has changed, remove the assert, and test thoroughly.
564+
assert(0);
565+
*posargs = plain_names;
566+
}
567+
else {
568+
*posargs = _Py_asdl_arg_seq_new(0, p->arena);
569+
}
562570
}
563571
return *posargs == NULL ? -1 : 0;
564572
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy