FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-135755: Document the new `PyFunction_GET_BUILTINS` macro by ZeroIntensity · Pull Request #135934 · python/cpython · GitHub

/ cpython Public
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .dat  (1) .rst  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
10 changes: 10 additions & 0 deletions Doc/c-api/function.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,16 @@ There are a few functions specific to Python functions.
do not do type checking. Passing anything other than an instance of
:c:data:`PyFunction_Type` is undefined behavior.

.. c:function:: PyObject *PyFunction_GET_BUILTINS(PyObject *op)

Return the dictionary used to look up builtins (which might be ``NULL``)
when calling function *op*.

This function cannot fail and does not do error checking; passing anything
other than an instance of :c:data:`PyFunction_Type` is undefined behavior.
There is no ``PyFunction_Get*`` equivalent for this function.
Comment on lines +150 to +152

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Hm, I don't think C API WG would approve.
Should this function be in a private header (and with an underscore) instead? It looks untested as well.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

It's sort of tested. I'm not opposed to making it private.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

That looks like it's used in a test -- the test assumes that it's working?
Yeah, the more I look into it, the better making it private seems.

cc @ericsnowcurrently, who added PyFunction_GET_BUILTINS in #133128

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I'll put up an alternate PR.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

FWIW, I agree with making it internal-only.


.. versionadded 3.14

.. c:function:: int PyFunction_AddWatcher(PyFunction_WatchCallback callback)

Expand Down
3 changes: 3 additions & 0 deletions Doc/data/refcounts.dat
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -966,6 +966,9 @@ PyFunction_GetAnnotations:PyObject*:op:0:
PyFunction_GET_ANNOTATIONS:PyObject*::0:
PyFunction_GET_ANNOTATIONS:PyObject*:op:0:

PyFunction_GET_BUILTINS:PyObject*::0:
PyFunction_GET_BUILTINS:PyObject*:op:0:

PyFunction_GetClosure:PyObject*::0:
PyFunction_GetClosure:PyObject*:op:0:

Expand Down

Back | FazBrowse Home | New Git URL