Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

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

Provide feedback

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

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-104799: Default missing lists in AST to the empty list#104834

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
JelleZijlstra merged 7 commits intopython:mainfromJelleZijlstra:defaultempty
Jun 2, 2023

Conversation

JelleZijlstra
Copy link
Member

@JelleZijlstraJelleZijlstra commentedMay 24, 2023
edited by github-actionsbot
Loading

Motivated by#104799: avoid breaking backward compatibility with the manual creation ofast.FunctionDef nodes. Now, if a list-type field is missing, we simply default to the empty list.

This affects all AST nodes though, not just the new ones.


📚 Documentation preview 📚:https://cpython-previews--104834.org.readthedocs.build/

@JelleZijlstra
Copy link
MemberAuthor

(This PR is on top of the changes from#104828.)

@JelleZijlstra
Copy link
MemberAuthor

Ideally I'd like this to go into 3.12 to fix the BC issues in#104799, but maybe it's too late.

@markshannon
Copy link
Member

So I understand correctly, this changes the representation of a missing list fromNULL toPyList_New(0). Correct?

I am a little concerned (just a little) about the performance implications.
Which nodes will this affect in practice?

@JelleZijlstra
Copy link
MemberAuthor

So I understand correctly, this changes the representation of a missing list fromNULL toPyList_New(0). Correct?

No, it changes from raising a TypeError to PyList_New(0). This is easier to see in the generated code than in the code generator:

@@ -9306,10 +9404,12 @@ obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*             return 1;         }         if (tmp == NULL) {-            PyErr_SetString(PyExc_TypeError, "required field \"generators\" missing from DictComp");-            return 1;+            tmp = PyList_New(0);+            if (tmp == NULL) {+                return 1;+            }         }-        else {+        {             int res;             Py_ssize_t len;             Py_ssize_t i;

So this shouldn't affect performance for code that was already working.

@JelleZijlstraJelleZijlstra merged commit77d2579 intopython:mainJun 2, 2023
@JelleZijlstraJelleZijlstra deleted the defaultempty branchJune 2, 2023 01:39
@JelleZijlstraJelleZijlstra added the needs backport to 3.12only security fixes labelJun 2, 2023
@miss-islington
Copy link
Contributor

Thanks@JelleZijlstra for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull requestJun 2, 2023
…onGH-104834)(cherry picked from commit77d2579)Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
@bedevere-bot
Copy link

GH-105213 is a backport of this pull request to the3.12 branch.

@bedevere-botbedevere-bot removed the needs backport to 3.12only security fixes labelJun 2, 2023
JelleZijlstra added a commit that referenced this pull requestJun 2, 2023
…104834) (#105213)(cherry picked from commit77d2579)Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
@JelleZijlstraJelleZijlstra restored the defaultempty branchSeptember 10, 2024 23:37
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@isidenticalisidenticalAwaiting requested review from isidenticalisidentical is a code owner

@pablogsalpablogsalAwaiting requested review from pablogsal

@lysnikolaoulysnikolaouAwaiting requested review from lysnikolaou

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

5 participants
@JelleZijlstra@markshannon@miss-islington@bedevere-bot@AlexWaygood

[8]ページ先頭

©2009-2025 Movatter.jp