◐ Shell
reader mode source ↗
Skip to content

bpo-29622: make AST constructor accepts less than enough number of positional arguments#249

Merged
methane merged 3 commits into
python:masterfrom
methane:bpo-29622
Feb 23, 2017
Merged

bpo-29622: make AST constructor accepts less than enough number of positional arguments#249
methane merged 3 commits into
python:masterfrom
methane:bpo-29622

Conversation

@methane

@methane methane commented Feb 23, 2017

Copy link
Copy Markdown
Member

Currently, AST constructor accepts

a. empty arguments
b. positional arguments, only when it's length is exactly same to number of fields
c. keyword arguments. No check for missing required fields.

Only (b) is strict. And it require argument even if matching field is optional.
This pull request removes the strict check.
Missing required field can be detected when compiling AST though.

@methane methane changed the title bpo-29622: Loosen restriction of number of positional argument of AST constructor Feb 23, 2017
@methane

methane commented Feb 23, 2017

Copy link
Copy Markdown
Member Author

I implemented minimum number of arguments.
But I still don't know should I check it, since AST constructor doesn't check it when keyword argument is used.

@takluyver

Copy link
Copy Markdown
Contributor

Could I ask that we don't make arguments required, even if you need them to construct a valid AST? I have a pair of little side projects (astsearch and astcheck) which rely on the ability to instantiate incomplete AST objects. I reuse these as templates, so you can check for things like 'for loop with an else clause' without specifying any of the required pieces of a for loop.

Obviously this isn't what the AST classes are intended for, but it works pretty nicely. And yes, I am being this guy:

xkcd 'Workflow'

@methane

methane commented Feb 23, 2017

Copy link
Copy Markdown
Member Author

@takluyver Thank you. I decided to revert last commit.

@takluyver

Copy link
Copy Markdown
Contributor

Thanks @methane :-)

@methane methane changed the title bpo-29622: Make trailing optional fields to optional arguments of AST type Feb 23, 2017
@methane methane changed the title bpo-29622: make AST constructor accept less than enough number of positional arguments Feb 23, 2017
@methane methane merged commit 4c78c52 into python:master Feb 23, 2017
@Carreau

Carreau commented Feb 23, 2017

Copy link
Copy Markdown
Contributor

Thanks !

@methane methane deleted the bpo-29622 branch January 29, 2018 06:05
akruis added a commit to akruis/cpython that referenced this pull request May 21, 2021
…n API

Stackless does not support custom frame evaluation functions defined by
PEP 523. If an extension module sets a custom frame evaluation function,
Stackless now terminates to prevent undefined behavior.

(cherry picked from commit d57b317)
akruis added a commit to akruis/cpython that referenced this pull request May 27, 2021
…n API

Stackless does not support custom frame evaluation functions defined by
PEP 523. If an extension module sets a custom frame evaluation function,
Stackless now terminates to prevent undefined behavior.
jaraco pushed a commit that referenced this pull request Dec 2, 2022
jaraco added a commit to jaraco/cpython that referenced this pull request Feb 17, 2023
…athsep

Honor '/'-separated names in ResourceContainer.joinpath.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants