Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
4d0f508
gh-108512: Add and use new replacements for PySys_GetObject()
serhiy-storchaka Sep 20, 2023
eb42b39
Update Misc/stable_abi.toml
serhiy-storchaka Oct 18, 2023
2d4588d
Merge branch 'main' into capi-PySys_GetAttr
serhiy-storchaka Oct 18, 2023
2eb9533
Add tests.
serhiy-storchaka Oct 19, 2023
9fc2f3d
Apply suggestions from code review
serhiy-storchaka Oct 19, 2023
65713ce
Address review comments.
serhiy-storchaka Oct 19, 2023
e6ecf11
Check that the name is a string.
serhiy-storchaka Oct 19, 2023
8a0f5f2
Merge remote-tracking branch 'refs/remotes/origin/capi-PySys_GetAttr'…
serhiy-storchaka Oct 19, 2023
516829e
Make the new C API not public.
serhiy-storchaka Oct 19, 2023
9503aaf
Remove from Misc/stable_abi.toml.
serhiy-storchaka Oct 19, 2023
e2857ef
Merge branch 'main' into capi-PySys_GetAttr
serhiy-storchaka Jan 28, 2025
dc26ec2
Add to the limited C API.
serhiy-storchaka Jan 28, 2025
104dcc2
Replace few new occurrences of PySys_GetObject().
serhiy-storchaka Jan 28, 2025
cf75fc3
Update the documentation.
serhiy-storchaka Jan 28, 2025
9434659
Clean up.
serhiy-storchaka Jan 28, 2025
56639d8
Fix a typo.
serhiy-storchaka Jan 28, 2025
b40a665
Merge branch 'main' into capi-PySys_GetAttr
serhiy-storchaka Feb 6, 2025
03b9c0a
Merge branch 'main' into capi-PySys_GetAttr
serhiy-storchaka Feb 6, 2025
5d793c5
Merge remote-tracking branch 'refs/remotes/origin/capi-PySys_GetAttr'…
serhiy-storchaka Feb 6, 2025
09869ed
Merge branch 'main' into capi-PySys_GetAttr
serhiy-storchaka Feb 25, 2025
439bc3c
Merge branch 'main' into capi-PySys_GetAttr
serhiy-storchaka May 21, 2025
93ab31b
Move to 3.15.
serhiy-storchaka May 21, 2025
154a82a
Address review comments.
serhiy-storchaka May 22, 2025
81c7605
Improve tests.
serhiy-storchaka May 22, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'main' into capi-PySys_GetAttr
  • Loading branch information
serhiy-storchaka committed Feb 25, 2025
commit 09869edbf7106836472d5c2aa01146f667c7ec0e
8 changes: 3 additions & 5 deletions Modules/_cursesmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ static const char PyCursesVersion[] = "2.2";
#include "pycore_capsule.h" // _PyCapsule_SetTraverse()
#include "pycore_long.h" // _PyLong_GetZero()
#include "pycore_structseq.h" // _PyStructSequence_NewType()
#include "pycore_sysmodule.h" // _PySys_GetOptionalAttrString()

#ifdef __hpux
#define STRICT_SYSV_CURSES
Expand Down Expand Up @@ -3543,15 +3542,14 @@ _curses_setupterm_impl(PyObject *module, const char *term, int fd)
if (fd == -1) {
PyObject* sys_stdout;

sys_stdout = PySys_GetAttrString("stdout");
if (sys_stdout == NULL) {
if (PySys_GetOptionalAttrString("stdout", &sys_stdout) < 0) {
return NULL;
}

if (sys_stdout == Py_None) {
if (sys_stdout == NULL || sys_stdout == Py_None) {
cursesmodule_state *state = get_cursesmodule_state(module);
PyErr_SetString(state->error, "lost sys.stdout");
Py_DECREF(sys_stdout);
Py_XDECREF(sys_stdout);
return NULL;
}

Expand Down
5 changes: 2 additions & 3 deletions Modules/_tkinter.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ Copyright (C) 1994 Steen Lumholt.
#endif

#include "pycore_long.h" // _PyLong_IsNegative()
#include "pycore_sysmodule.h" // _PySys_GetOptionalAttrString()

#ifdef MS_WINDOWS
# include <windows.h>
Expand Down Expand Up @@ -145,7 +144,7 @@ _get_tcl_lib_path(void)
int stat_return_value;
PyObject *prefix;

PyObject *prefix = PySys_GetAttrString("base_prefix");
(void) PySys_GetOptionalAttrString("base_prefix", &prefix);
if (prefix == NULL) {
return NULL;
}
Expand Down Expand Up @@ -3520,7 +3519,7 @@ PyInit__tkinter(void)

/* This helps the dynamic loader; in Unicode aware Tcl versions
it also helps Tcl find its encodings. */
uexe = PySys_GetAttrString("executable");
(void) PySys_GetOptionalAttrString("executable", &uexe);
if (uexe && PyUnicode_Check(uexe)) { // sys.executable can be None
cexe = PyUnicode_EncodeFSDefault(uexe);
Py_DECREF(uexe);
Expand Down
6 changes: 2 additions & 4 deletions Modules/syslogmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ Revision history:

#include "Python.h"
#include "osdefs.h" // SEP
#include "pycore_sysmodule.h" // _PySys_GetOptionalAttrString()

#include <syslog.h>

Expand Down Expand Up @@ -90,10 +89,9 @@ syslog_get_argv(void)
Py_ssize_t argv_len, scriptlen;
PyObject *scriptobj;
Py_ssize_t slash;
PyObject *argv = PySys_GetAttrString("argv");
PyObject *argv;

if (argv == NULL) {
PyErr_Clear();
if (PySys_GetOptionalAttrString("argv", &argv) <= 0) {
return NULL;
}

Expand Down
1 change: 0 additions & 1 deletion Objects/moduleobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include "pycore_object.h" // _PyType_AllocNoTrack
#include "pycore_pyerrors.h" // _PyErr_FormatFromCause()
#include "pycore_pystate.h" // _PyInterpreterState_GET()
#include "pycore_sysmodule.h" // _PySys_GetOptionalAttrString()

#include "osdefs.h" // MAXPATHLEN

Expand Down
4 changes: 2 additions & 2 deletions Python/_warnings.c
Original file line number Diff line number Diff line change
Expand Up @@ -562,8 +562,8 @@ show_warning(PyThreadState *tstate, PyObject *filename, int lineno,
goto error;
}

f_stderr = PySys_GetAttr(&_Py_ID(stderr));
if (f_stderr == NULL) {
if (PySys_GetOptionalAttr(&_Py_ID(stderr), &f_stderr) <= 0) {
fprintf(stderr, "lost sys.stderr\n");
goto error;
}

Expand Down
1 change: 0 additions & 1 deletion Python/ceval.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#include "pycore_tuple.h" // _PyTuple_ITEMS()
#include "pycore_uop_ids.h" // Uops
#include "pycore_pyerrors.h"
#include "pycore_sysmodule.h" // _PySys_GetOptionalAttrString()

#include "pycore_dict.h"
#include "dictobject.h"
Expand Down
2 changes: 1 addition & 1 deletion Python/sysmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ PySys_GetAttr(PyObject *name)
}
PyObject *value;
if (PyDict_GetItemRef(sysdict, name, &value) == 0) {
PyErr_Format(PyExc_RuntimeError, "lost sys.%S", name);
PyErr_Format(PyExc_RuntimeError, "lost sys.%U", name);
}
return value;
}
Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.