Skip to content

Commit 458ef7d

Browse files
committed
Apply suggestions from code review
1 parent 659e573 commit 458ef7d

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

Doc/library/sys.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ always available. Unless explicitly noted otherwise, all variables are read-only
3131
means the :data:`sys.abiflags` member will always be available on all
3232
platforms starting from Python 3.16.
3333

34-
See :ref:`whatsnew314-sys-abiflags-change` in the *What's New* for more
35-
details.
34+
See the notes for :ref:`incoming change to sys.abiflags <whatsnew314-sys-abiflags-change>`
35+
in the *What's New* for more details.
3636

3737

3838
.. function:: addaudithook(hook)

Doc/whatsnew/3.14.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -932,6 +932,7 @@ sys
932932
* Schedule a change for availability of :data:`sys.abiflags` on Windows. A
933933
:exc:`DeprecationWarning` will be emitted if the :data:`sys.abiflags` member
934934
is accessed on Windows before Python 3.16.
935+
(Contributed by Xuehai Pan in :gh:`131717`.)
935936

936937
.. _whatsnew314-sys-abiflags-change:
937938

Python/sysmodule.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ module sys
7777
#ifndef ABIFLAGS
7878

7979
// XXX: remove this and related code after set sys.abiflags on Windows in 3.16.
80-
static int
81-
_warn_incoming_sys_abiflags_change()
80+
static inline int
81+
_warn_incoming_sys_abiflags_change(void)
8282
{
8383
return PyErr_WarnEx(
8484
PyExc_DeprecationWarning,
@@ -167,8 +167,7 @@ _PySys_GetOptionalAttr(PyObject *name, PyObject **value)
167167
#ifndef ABIFLAGS
168168
if (ret == 0 && _PyUnicode_EqualToASCIIString(name, "abiflags")) {
169169
if (_warn_incoming_sys_abiflags_change() < 0) {
170-
Py_XDECREF(*value);
171-
*value = NULL;
170+
Py_CLEAR(*value);
172171
return -1;
173172
}
174173
}
@@ -189,8 +188,7 @@ _PySys_GetOptionalAttrString(const char *name, PyObject **value)
189188
#ifndef ABIFLAGS
190189
if (ret == 0 && strcmp(name, "abiflags") == 0) {
191190
if (_warn_incoming_sys_abiflags_change() < 0) {
192-
Py_XDECREF(*value);
193-
*value = NULL;
191+
Py_CLEAR(*value);
194192
return -1;
195193
}
196194
}

0 commit comments

Comments
 (0)