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

Commit8fc8fbb

Browse files
authored
gh-85283: Build pwd extension with the limited C API (#116841)
Argument Clinic now uses the PEP 737 "%T" format to format type namefor the limited C API.
1 parent41e844a commit8fc8fbb

File tree

5 files changed

+16
-12
lines changed

5 files changed

+16
-12
lines changed

‎Doc/whatsnew/3.13.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1469,7 +1469,7 @@ Build Changes
14691469
* Building CPython now requires a compiler with support for the C11 atomic
14701470
library, GCC built-in atomic functions, or MSVC interlocked intrinsics.
14711471

1472-
* The ``errno``, ``fcntl``, ``grp``, ``md5``, ``resource``, ``winsound``,
1472+
* The ``errno``, ``fcntl``, ``grp``, ``md5``, ``pwd``, ``resource``, ``winsound``,
14731473
``_ctypes_test``, ``_multiprocessing.posixshmem``, ``_scproxy``, ``_stat``,
14741474
``_testimportmultiple`` and ``_uuid`` C extensions are now built with the
14751475
:ref:`limited C API<limited-c-api>`.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
The ``fcntl``and ``grp`` C extensions are now built with the:ref:`limited
1+
The ``fcntl``, ``grp``and ``pwd`` C extensions are now built with the:ref:`limited
22
C API <limited-c-api>`. (Contributed by Victor Stinner in:gh:`85283`.)

‎Modules/clinic/pwdmodule.c.h

Lines changed: 2 additions & 4 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎Modules/pwdmodule.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11

22
/* UNIX password file access module */
33

4+
// Need limited C API version 3.13 for PyMem_RawRealloc()
5+
#include"pyconfig.h"// Py_GIL_DISABLED
6+
#ifndefPy_GIL_DISABLED
7+
# definePy_LIMITED_API 0x030d0000
8+
#endif
9+
410
#include"Python.h"
511
#include"posixmodule.h"
612

13+
#include<errno.h>// ERANGE
714
#include<pwd.h>// getpwuid()
815
#include<unistd.h>// sysconf()
916

@@ -83,7 +90,7 @@ mkpwent(PyObject *module, struct passwd *p)
8390
if (item == NULL) { \
8491
goto error; \
8592
} \
86-
PyStructSequence_SET_ITEM(v, setIndex++, item); \
93+
PyStructSequence_SetItem(v, setIndex++, item); \
8794
} while(0)
8895

8996
SET_STRING(p->pw_name);

‎Tools/clinic/libclinic/converter.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -426,13 +426,12 @@ def bad_argument(self, displayname: str, expected: str, *, limited_capi: bool, e
426426
iflimited_capi:
427427
ifexpected_literal:
428428
return (f'PyErr_Format(PyExc_TypeError, '
429-
f'"{{{{name}}}}(){displayname} must be{expected}, not %.50s", '
430-
f'{{argname}} == Py_None ? "None" : Py_TYPE({{argname}})->tp_name);')
429+
f'"{{{{name}}}}(){displayname} must be{expected}, not %T", '
430+
f'{{argname}});')
431431
else:
432432
return (f'PyErr_Format(PyExc_TypeError, '
433-
f'"{{{{name}}}}(){displayname} must be %.50s, not %.50s", '
434-
f'"{expected}", '
435-
f'{{argname}} == Py_None ? "None" : Py_TYPE({{argname}})->tp_name);')
433+
f'"{{{{name}}}}(){displayname} must be %s, not %T", '
434+
f'"{expected}", {{argname}});')
436435
else:
437436
ifexpected_literal:
438437
expected=f'"{expected}"'

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp