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

bpo-43541: Fix PyEval_EvalCodeEx() regression#24918

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
vstinner merged 1 commit intopython:masterfromvstinner:eval_code_ex
Mar 18, 2021
Merged

bpo-43541: Fix PyEval_EvalCodeEx() regression#24918

vstinner merged 1 commit intopython:masterfromvstinner:eval_code_ex
Mar 18, 2021

Conversation

vstinner
Copy link
Member

@vstinnervstinner commentedMar 18, 2021
edited by bedevere-bot
Loading

  • Remove an assertion which required CO_NEWLOCALS and CO_OPTIMIZED
    code flags. It is ok to call this function on a code with these
    flags set.
  • Fix reference counting on builtins: remove Py_DECREF().
    Fix regression introduced in the
    commit46496f9.

Add also a comment to document that _PyEval_BuiltinsFromGlobals()
returns a borrowed reference.

https://bugs.python.org/issue43541

* Remove an assertion which required CO_NEWLOCALS and CO_OPTIMIZED  code flags. It is ok to call this function on a code with these  flags set.* Fix reference counting on builtins: remove Py_DECREF().  Fix regression introduced in the  commit46496f9.Add also a comment to document that _PyEval_BuiltinsFromGlobals()returns a borrowed reference.
@markshannon
Copy link
Member

Why not have_PyEval_BuiltinsFromGlobals() return a strong reference?
Returning borrowed references is always risky.

Otherwise, looks good.

@vstinner
Copy link
MemberAuthor

Why not have _PyEval_BuiltinsFromGlobals() return a strong reference? Returning borrowed references is always risky.

Before my46496f9 change, _PyEval_BuiltinsFromGlobals() could call PyDict_New() sometimes: strong reference. With my change, it doesn't have to create a new strong reference anymore. So I chose to return a borrowed reference.

But I tried to keep a strong reference as soon as possible where it looks relevant. I compared with Python 3.9 behavior which doesn't hold strong references while using builtins.

I know that there are some crazy ways of crashing Python caused by borrowed references, but in general it's fine and Py_INCREF/Py_DECREF has an impact on performance. For example,https://bugs.python.org/issue15108 is a bug but it was closed as "not a bug". If someone spots a dangerous usage of builtins, INCREF/DECREF can be added around the usage.

@vstinnervstinner merged commitfc980e0 intopython:masterMar 18, 2021
@vstinnervstinner deleted the eval_code_ex branchMarch 18, 2021 13:51
@vstinner
Copy link
MemberAuthor

I merged my PR.

Otherwise, looks good.

Thanks for the review Mark!

@markshannon
Copy link
Member

Using a strong reference would have no negative impact on performance, sincePyFunction_NewWithQualName needs to increment the refcount anyway. All the other uses are in legacy API where we don't care about performance.

jab added a commit to jab/cpython that referenced this pull requestMar 20, 2021
* master: (129 commits)  bpo-43452: Micro-optimizations to PyType_Lookup (pythonGH-24804)  bpo-43517: Fix false positive in detection of circular imports (python#24895)  bpo-43494: Make some minor changes to lnotab notes (pythonGH-24861)  Mention that code.co_lnotab is deprecated in what's new for 3.10. (python#24902)  bpo-43244: Remove symtable.h header file (pythonGH-24910)  bpo-43466: Add --with-openssl-rpath configure option (pythonGH-24820)  Fix a typo in c-analyzer (pythonGH-24468)  bpo-41561: Add workaround for Ubuntu's custom security level (pythonGH-24915)  bpo-43521: Allow ast.unparse with empty sets and NaN (pythonGH-24897)  bpo-43244: Remove the PyAST_Validate() function (pythonGH-24911)  bpo-43541: Fix PyEval_EvalCodeEx() regression (pythonGH-24918)  bpo-43244: Fix test_peg_generators on Windows (pythonGH-24913)  bpo-39342: Expose X509_V_FLAG_ALLOW_PROXY_CERTS in ssl module (pythonGH-18011)  bpo-43244: Fix test_peg_generator for PyAST_Validate() (pythonGH-24912)  bpo-42128: Add 'missing :' syntax error message to match statements (pythonGH-24733)  bpo-43244: Add pycore_ast.h header file (pythonGH-24908)  bpo-43244: Rename pycore_ast.h to pycore_ast_state.h (pythonGH-24907)  Remove unnecessary imports in the grammar parser (pythonGH-24904)  bpo-35883: Py_DecodeLocale() escapes invalid Unicode characters (pythonGH-24843)  Add PEP 626 to what's new in 3.10. (python#24892)  ...
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@markshannonmarkshannonAwaiting requested review from markshannon

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

Successfully merging this pull request may close these issues.

4 participants
@vstinner@markshannon@the-knights-who-say-ni@bedevere-bot

[8]ページ先頭

©2009-2025 Movatter.jp