GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-108512: Add and use new replacements for PySys_GetObject() by serhiy-storchaka · Pull Request #111035 · python/cpython

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Oct 18, 2023 •
edited by github-actions Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Add functions PySys_GetAttr(), PySys_GetAttrString(), PySys_GetOptionalAttr() and PySys_GetOptionalAttrString().

  • Issue: C API: Add a replacement for PySys_GetObject #108512

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@serhiy-storchaka
pythongh-108512: Add and use new replacements for PySys_GetObject()
4d0f508
Add functions PySys_GetAttr(), PySys_GetAttrString(),
PySys_GetOptionalAttr() and PySys_GetOptionalAttrString().
@serhiy-storchaka serhiy-storchaka added the topic-C-API label Oct 18, 2023
@serhiy-storchaka
serhiy-storchaka requested a review from vstinner October 18, 2023 12:11
@serhiy-storchaka
serhiy-storchaka requested review from iritkatriel and kumaraditya303 as code owners October 18, 2023 12:11
@bedevere-app bedevere-app Bot mentioned this pull request Oct 18, 2023
C API: Add a replacement for PySys_GetObject #108512
Closed
@bedevere-app bedevere-app Bot added the awaiting core review label Oct 18, 2023
@serhiy-storchaka
Update Misc/stable_abi.toml
eb42b39
@serhiy-storchaka
serhiy-storchaka requested review from a team and encukou as code owners October 18, 2023 14:10
@serhiy-storchaka
Merge branch 'main' into capi-PySys_GetAttr
2d4588d
vstinner
vstinner reviewed Oct 18, 2023
View reviewed changes

@vstinner vstinner left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Would it be possible to leave changes to use these changes aside, in a separated PR, so we can focus only on the API, doc and tests on the new functions?

The function is called "GetAttr" but in the doc, you wrote "if the object exists". IMO "if the attribute exists" is more appropriate.

Is it required to add these new functions to the stable ABI in Python 3.13? Can we wait one Python release to see how it does, before add them to the stable ABI?

Would it be possible to add tests?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Doc/c-api/sys.rst Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/c-api/sys.rst Outdated
Comment on lines +251 to +256
If the object exists, set *\*result* to a new :term:`strong reference`
to the object and return ``1``.
If the object does not exist, set *\*result* to ``NULL`` and return ``0``,
without setting an exception.
If other error occurred, set an exception, set *\*result* to ``NULL`` and
return ``-1``.

@vstinner vstinner Oct 18, 2023

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I suggest to use a list and start with the return value, so it's easier to see the 3 cases:

Suggested change
If the object exists, set *\*result* to a new :term:`strong reference`
to the object and return ``1``.
If the object does not exist, set *\*result* to ``NULL`` and return ``0``,
without setting an exception.
If other error occurred, set an exception, set *\*result* to ``NULL`` and
return ``-1``.
* Return ``1`` and set *\*result* to a new :term:`strong reference`
to the object if the attribute exists.
* Return ``0`` without setting an exception and set *\*result* to ``NULL``
if the attribute does not exist.
* Return ``-1``, set an exception and set *\*result* to ``NULL``
if an error occurred.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@serhiy-storchaka serhiy-storchaka Oct 19, 2023

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

"Return and then set exception and variable" looks like a wrong sequence to me. It cannot do anything after returning.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@vstinner vstinner May 21, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Just say it in the opposite order in this case:

Set an exception, set *\*result* to ``NULL``, and return ``-1``, if an error occurred.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

serhiy-storchaka reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
serhiy-storchaka and others added 2 commits October 19, 2023 10:57
@serhiy-storchaka
Add tests.
2eb9533
@serhiy-storchaka @vstinner
Apply suggestions from code review
9fc2f3d
Co-authored-by: Victor Stinner <[email protected]>
vstinner
vstinner reviewed Oct 19, 2023
View reviewed changes
Comment thread Lib/test/test_capi/test_misc.py Outdated
with support.swap_attr(sys, '\U0001f40d', 42):
self.assertEqual(sys_getattr('\U0001f40d'), 42)

with self.assertRaisesRegex(RuntimeError, r'lost sys\.nonexisting'):

@vstinner vstinner Oct 19, 2023

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

This error message is surprising. sys has no attribute "nonexisting". It's not "lost", it simply doesn't exist.

I would prefer to always raise AttributeError with a message like "module 'sys' has no attribute 'x'", similar than in Python:

>>> import sys
>>> sys.x
AttributeError: module 'sys' has no attribute 'x'

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@serhiy-storchaka serhiy-storchaka Oct 19, 2023

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

It leaves no use cases for PySys_GetAttr(). They all can be replaced with PySys_GetOptionalAttr() followed by PyErr_SetString(PyExc_RuntimeError,).

If you leave PySys_GetAttr(), you will always use it with PyErr_ExceptionMatches(PyExc_AttributeError) followed by PyErr_SetString(PyExc_RuntimeError,).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Lib/test/test_capi/test_misc.py Outdated
# CRASHES sys_getattr(NULL)

def test_sys_getoptionalattr(self):
sys_getattr = _testcapi.sys_getoptionalattr

@vstinner vstinner Oct 19, 2023

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

It's surprising that in all tests, the function is called "sys_getattr", whereas here you test PySys_GetOptionalAttr(), not PySys_GetAttr().

I suggest to rename the variable t o"sys_getoptionalattr", or even PySys_GetOptionalAttr() since this is a C API test. It would be more explicit to use the name of the C API.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@serhiy-storchaka serhiy-storchaka Oct 19, 2023

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Actually, it was exactly what I wrote initially, but in last minute I replaced all names with the same name to make reading easy. But if you think that it does not help, I'll restore previous names.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Lib/test/test_capi/test_misc.py Outdated
self.assertEqual(sys_getattr('\U0001f40d'.encode()), 42)

self.assertIs(sys_getattr(b'nonexisting'), AttributeError)
self.assertRaises(UnicodeDecodeError, sys_getattr, b'\xff')

@vstinner vstinner Oct 19, 2023

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Can you add a UnicodeDecodeError to test_sys_getattr() as well?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@serhiy-storchaka serhiy-storchaka Oct 19, 2023

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

No, PySys_GetAttr() does not raise UnicodeDecodeError. The wrapper does, but we do not test PyArg_Parse() here.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Modules/_testcapimodule.c Outdated

switch (PySys_GetOptionalAttr(name, &value)) {
case -1:
assert(value == NULL);

@vstinner vstinner Oct 19, 2023

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I suggest adding: assert(PyErr_Occurred());. Same remark in sys_getoptionalattrstring().

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@serhiy-storchaka serhiy-storchaka Oct 19, 2023

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Isn't there a check that each function that returns NULL should also set an exception? I relied on this in all other tests.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Modules/_testcapimodule.c Outdated
return value;
default:
Py_FatalError("PySys_GetOptionalAttr() returned invalid code");
Py_UNREACHABLE();

@vstinner vstinner Oct 19, 2023

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

It should not be needed, Py_FatalError() is annotated with _Py_NO_RETURN. Same remark in sys_getoptionalattrstring().

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@serhiy-storchaka serhiy-storchaka Oct 19, 2023

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Well, removing.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Modules/_testcapimodule.c Outdated
}
if (result == NULL) {
result = PyExc_AttributeError;
Py_INCREF(PyExc_AttributeError);

@vstinner vstinner Oct 19, 2023

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I don't understand this code path. The function must return NULL and raise an exception if the attribute does not exist. This code path must never be reached according to the API doc.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@serhiy-storchaka serhiy-storchaka Oct 19, 2023

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I added it exactly to test that it never happens. But perhaps it can be removed.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@serhiy-storchaka

serhiy-storchaka commented Oct 19, 2023

Copy link
Copy Markdown
Member Author

Would it be possible to leave changes to use these changes aside, in a separated PR, so we can focus only on the API, doc and tests on the new functions?

It is easy to see the effect of these changes if they are in a single PR. Also, it replaces old private functions with new public API that is impossible if they are still used. If you prefer, I will split this PR into two parts after the development of the new API is complete, immediately before merging.

The function is called "GetAttr" but in the doc, you wrote "if the object exists". IMO "if the attribute exists" is more appropriate.

These are the words used in the description of the existing function PySys_GetObject(). Module attributes are rarely referred to as "attributes". They are more often referred as module variables, module constants, module globals. Sphynx has a special role :data: for this instead of more general :attr:.

Is it required to add these new functions to the stable ABI in Python 3.13? Can we wait one Python release to see how it does, before add them to the stable ABI?

What exactly do you propose? Isn't it a point that we can suggest them as replacements for PySys_GetObject() and deprecate the latter in distant future? Should not all new public API be in the stable ABI or not be public at all?

Would it be possible to add tests?

Good point, I forgot about this. Done.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner

vstinner commented Oct 19, 2023

Copy link
Copy Markdown
Member

Module attributes are rarely referred to as "attributes".

Well, trying to get sys.x raises an AttributeError, not a NameError :-)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner

vstinner commented Oct 19, 2023

Copy link
Copy Markdown
Member

Should not all new public API be in the stable ABI or not be public at all?

I'm asking if we should only add the API to Include/cpython/ in Python 3.13, and wait for Python 3.14 to add it to the limited API. Just in case if something goes wrong, if the API changes when we notice issues. If it lands directly in the stable ABI, we can no longer change it, it's too late.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

serhiy-storchaka added 5 commits October 19, 2023 12:00
@serhiy-storchaka
Address review comments.
65713ce
@serhiy-storchaka
Check that the name is a string.
e6ecf11
@serhiy-storchaka
Merge remote-tracking branch 'refs/remotes/origin/capi-PySys_GetAttr'…
8a0f5f2
… into capi-PySys_GetAttr
@serhiy-storchaka
Make the new C API not public.
516829e
@serhiy-storchaka
Remove from Misc/stable_abi.toml.
9503aaf
vstinner
vstinner reviewed Oct 20, 2023
View reviewed changes

@vstinner vstinner left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

About the exception, I see two options:

  • We consider that we get an object from a namespace, similar to LOAD_GLOBAL, and so NameError should be raised. IMO the function should be called PySys_GetVar() in this case. Example: https://docs.python.org/dev/c-api/frame.html#c.PyFrame_GetVar raises NameError.

  • Or we consider that we are getting an attribute, PySys_GetAttr() name is good, and AttributeError should be raised in this case.

For me, RuntimeError is just meaningless and it should be avoided. RuntimeError means everything and nothing: "something failed". Thanks Python...

In Python, usually I consider that the sys module is an object and I get sys attributes with getattr(sys, "stdout") which raises AttributeError.

In Python, I'm not even sure how to treat sys as a namespace. sys.__dict__['stdout'] raises KeyError, not NameError.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@serhiy-storchaka
serhiy-storchaka marked this pull request as draft January 10, 2024 14:25
@bedevere-app bedevere-app Bot removed the awaiting core review label Jan 10, 2024
serhiy-storchaka added 4 commits January 28, 2025 12:00
@serhiy-storchaka
Merge branch 'main' into capi-PySys_GetAttr
e2857ef
@serhiy-storchaka
Add to the limited C API.
dc26ec2
@serhiy-storchaka
Replace few new occurrences of PySys_GetObject().
104dcc2
@serhiy-storchaka
Update the documentation.
cf75fc3
@bedevere-app bedevere-app Bot added the awaiting core review label Jan 28, 2025
@serhiy-storchaka serhiy-storchaka mentioned this pull request Jan 28, 2025
Add replacements for PySys_GetObject() capi-workgroup/decisions#54
Closed
@vstinner vstinner mentioned this pull request Jan 28, 2025
gh-129367: Add PySys_GetAttr() function #129369
Closed
serhiy-storchaka added 3 commits February 6, 2025 16:33
@serhiy-storchaka
Merge branch 'main' into capi-PySys_GetAttr
b40a665
@serhiy-storchaka
Merge branch 'main' into capi-PySys_GetAttr
03b9c0a
@serhiy-storchaka
Merge remote-tracking branch 'refs/remotes/origin/capi-PySys_GetAttr'…
5d793c5
… into capi-PySys_GetAttr
@serhiy-storchaka serhiy-storchaka mentioned this pull request Feb 6, 2025
gh-108512: Add and use new replacements for PySys_GetObject() (alt) #129736
Closed
@kumaraditya303
kumaraditya303 removed their request for review February 21, 2025 18:15
This was referenced Feb 24, 2025
gh-130163: Fix possible crashes related to PySys_GetObject() #130503
Merged
Crash when concurrently writing with print and concurrently modifying sys.stdout #130163
Closed
@serhiy-storchaka
Merge branch 'main' into capi-PySys_GetAttr
09869ed
@serhiy-storchaka
serhiy-storchaka marked this pull request as draft May 4, 2025 16:22
@bedevere-app bedevere-app Bot removed the awaiting core review label May 4, 2025
serhiy-storchaka added 2 commits May 21, 2025 22:02
@serhiy-storchaka
Merge branch 'main' into capi-PySys_GetAttr
439bc3c
@serhiy-storchaka
Move to 3.15.
93ab31b
vstinner
vstinner reviewed May 21, 2025
View reviewed changes
Comment thread Doc/c-api/sys.rst Outdated
Comment on lines +251 to +256
If the object exists, set *\*result* to a new :term:`strong reference`
to the object and return ``1``.
If the object does not exist, set *\*result* to ``NULL`` and return ``0``,
without setting an exception.
If other error occurred, set an exception, set *\*result* to ``NULL`` and
return ``-1``.

@vstinner vstinner May 21, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Just say it in the opposite order in this case:

Set an exception, set *\*result* to ``NULL``, and return ``-1``, if an error occurred.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

serhiy-storchaka reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread Modules/_testlimitedcapi/sys.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Python/sysmodule.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Python/sysmodule.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Doc/c-api/sys.rst Outdated
.. c:function:: PyObject *PySys_GetAttr(PyObject *name)

Get the attribute *name* of the :mod:`sys` module. Return a :term:`strong reference`.
Raise :exc:`RuntimeError` and return ``NULL`` if it does not exist.

@vstinner vstinner May 21, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Suggested change
Raise :exc:`RuntimeError` and return ``NULL`` if it does not exist.
Raise :exc:`RuntimeError` and return ``NULL`` if it does not exist or if the :mod:`sys` module cannot be found.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

serhiy-storchaka reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread Include/cpython/sysmodule.h Outdated
@@ -0,0 +1,23 @@
#ifndef Py_CPYTHON_SYSMODULE_H

@vstinner vstinner May 21, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Is this change related to the 4 new functions?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@serhiy-storchaka serhiy-storchaka May 22, 2025

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

No, it is a merging error.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Include/sysmodule.h Resolved

Uh oh!

There was an error while loading. Please reload this page.

serhiy-storchaka added 2 commits May 22, 2025 11:47
@serhiy-storchaka
Address review comments.
154a82a
@serhiy-storchaka
Improve tests.
81c7605
serhiy-storchaka
serhiy-storchaka commented May 22, 2025
View reviewed changes

@serhiy-storchaka serhiy-storchaka left a comment

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Thank you for review @vstinner.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Include/cpython/sysmodule.h Outdated
@@ -0,0 +1,23 @@
#ifndef Py_CPYTHON_SYSMODULE_H

@serhiy-storchaka serhiy-storchaka May 22, 2025

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

No, it is a merging error.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Include/sysmodule.h Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Modules/_testlimitedcapi/sys.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

vstinner
vstinner approved these changes May 22, 2025
View reviewed changes

@vstinner vstinner left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

LGTM

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Modules/_testlimitedcapi/sys.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot added the awaiting merge label May 22, 2025
@serhiy-storchaka
serhiy-storchaka marked this pull request as ready for review May 28, 2025 16:41
@bedevere-app bedevere-app Bot added awaiting core review and removed awaiting merge labels May 28, 2025
@serhiy-storchaka
serhiy-storchaka merged commit bac3fcb into python:main May 28, 2025
@bedevere-app bedevere-app Bot removed the awaiting core review label May 28, 2025
@serhiy-storchaka
serhiy-storchaka deleted the capi-PySys_GetAttr branch May 28, 2025 17:11
Pranjal095 pushed a commit to Pranjal095/cpython that referenced this pull request Jul 12, 2025
@serhiy-storchaka @Pranjal095
pythongh-108512: Add and use new replacements for PySys_GetObject() (p…
2b08792
…ythonGH-111035)

Add functions PySys_GetAttr(), PySys_GetAttrString(),
PySys_GetOptionalAttr() and PySys_GetOptionalAttrString().
taegyunkim pushed a commit to taegyunkim/cpython that referenced this pull request Aug 4, 2025
@serhiy-storchaka @taegyunkim
pythongh-108512: Add and use new replacements for PySys_GetObject() (p…
198f0ac
…ythonGH-111035)

Add functions PySys_GetAttr(), PySys_GetAttrString(),
PySys_GetOptionalAttr() and PySys_GetOptionalAttrString().
gostak-dd pushed a commit to gostak-dd/cpython that referenced this pull request Jun 2, 2026
@serhiy-storchaka @gostak-dd
pythongh-108512: Add and use new replacements for PySys_GetObject() (p…
2af1b11
…ythonGH-111035)

Add functions PySys_GetAttr(), PySys_GetAttrString(),
PySys_GetOptionalAttr() and PySys_GetOptionalAttrString().
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@vstinner vstinner vstinner approved these changes
@iritkatriel iritkatriel Awaiting requested review from iritkatriel
@encukou encukou Awaiting requested review from encukou encukou is a code owner
@ericsnowcurrently ericsnowcurrently Awaiting requested review from ericsnowcurrently ericsnowcurrently is a code owner
@FFY00 FFY00 Awaiting requested review from FFY00 FFY00 is a code owner
@markshannon markshannon Awaiting requested review from markshannon markshannon is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

topic-C-API

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@serhiy-storchaka @vstinner
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.