Skip to content

Commit a93577f

Browse files
authored
Merge branch 'main' into text_sign_annot
2 parents 9c11c50 + 44fc378 commit a93577f

37 files changed

Lines changed: 1016 additions & 703 deletions

Doc/whatsnew/3.13.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -942,6 +942,13 @@ Porting to Python 3.13
942942
and ``setitimer()`` functions.
943943
(Contributed by Victor Stinner in :gh:`108765`.)
944944

945+
* ``Python.h`` no longer includes the ``<ctype.h>`` standard header file. If
946+
needed, it should now be included explicitly. For example, it provides
947+
``isalpha()`` and ``tolower()`` functions which are locale dependent. Python
948+
provides locale independent functions, like :c:func:`!Py_ISALPHA` and
949+
:c:func:`!Py_TOLOWER`.
950+
(Contributed by Victor Stinner in :gh:`108765`.)
951+
945952
Deprecated
946953
----------
947954

Include/Python.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
// Include standard header files
1919
#include <assert.h> // assert()
20-
#include <ctype.h> // tolower()
2120
#include <inttypes.h> // uintptr_t
2221
#include <limits.h> // INT_MAX
2322
#include <math.h> // HUGE_VAL

Include/exports.h

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,29 @@
11
#ifndef Py_EXPORTS_H
22
#define Py_EXPORTS_H
33

4+
/* Declarations for symbol visibility.
5+
6+
PyAPI_FUNC(type): Declares a public Python API function and return type
7+
PyAPI_DATA(type): Declares public Python data and its type
8+
PyMODINIT_FUNC: A Python module init function. If these functions are
9+
inside the Python core, they are private to the core.
10+
If in an extension module, it may be declared with
11+
external linkage depending on the platform.
12+
13+
As a number of platforms support/require "__declspec(dllimport/dllexport)",
14+
we support a HAVE_DECLSPEC_DLL macro to save duplication.
15+
*/
16+
17+
/*
18+
All windows ports, except cygwin, are handled in PC/pyconfig.h.
19+
20+
Cygwin is the only other autoconf platform requiring special
21+
linkage handling and it uses __declspec().
22+
*/
23+
#if defined(__CYGWIN__)
24+
# define HAVE_DECLSPEC_DLL
25+
#endif
26+
427
#if defined(_WIN32) || defined(__CYGWIN__)
528
#if defined(Py_ENABLE_SHARED)
629
#define Py_IMPORTED_SYMBOL __declspec(dllimport)
@@ -33,4 +56,53 @@
3356
#endif
3457
#endif
3558

59+
/* only get special linkage if built as shared or platform is Cygwin */
60+
#if defined(Py_ENABLE_SHARED) || defined(__CYGWIN__)
61+
# if defined(HAVE_DECLSPEC_DLL)
62+
# if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
63+
# define PyAPI_FUNC(RTYPE) Py_EXPORTED_SYMBOL RTYPE
64+
# define PyAPI_DATA(RTYPE) extern Py_EXPORTED_SYMBOL RTYPE
65+
/* module init functions inside the core need no external linkage */
66+
/* except for Cygwin to handle embedding */
67+
# if defined(__CYGWIN__)
68+
# define PyMODINIT_FUNC Py_EXPORTED_SYMBOL PyObject*
69+
# else /* __CYGWIN__ */
70+
# define PyMODINIT_FUNC PyObject*
71+
# endif /* __CYGWIN__ */
72+
# else /* Py_BUILD_CORE */
73+
/* Building an extension module, or an embedded situation */
74+
/* public Python functions and data are imported */
75+
/* Under Cygwin, auto-import functions to prevent compilation */
76+
/* failures similar to those described at the bottom of 4.1: */
77+
/* http://docs.python.org/extending/windows.html#a-cookbook-approach */
78+
# if !defined(__CYGWIN__)
79+
# define PyAPI_FUNC(RTYPE) Py_IMPORTED_SYMBOL RTYPE
80+
# endif /* !__CYGWIN__ */
81+
# define PyAPI_DATA(RTYPE) extern Py_IMPORTED_SYMBOL RTYPE
82+
/* module init functions outside the core must be exported */
83+
# if defined(__cplusplus)
84+
# define PyMODINIT_FUNC extern "C" Py_EXPORTED_SYMBOL PyObject*
85+
# else /* __cplusplus */
86+
# define PyMODINIT_FUNC Py_EXPORTED_SYMBOL PyObject*
87+
# endif /* __cplusplus */
88+
# endif /* Py_BUILD_CORE */
89+
# endif /* HAVE_DECLSPEC_DLL */
90+
#endif /* Py_ENABLE_SHARED */
91+
92+
/* If no external linkage macros defined by now, create defaults */
93+
#ifndef PyAPI_FUNC
94+
# define PyAPI_FUNC(RTYPE) Py_EXPORTED_SYMBOL RTYPE
95+
#endif
96+
#ifndef PyAPI_DATA
97+
# define PyAPI_DATA(RTYPE) extern Py_EXPORTED_SYMBOL RTYPE
98+
#endif
99+
#ifndef PyMODINIT_FUNC
100+
# if defined(__cplusplus)
101+
# define PyMODINIT_FUNC extern "C" Py_EXPORTED_SYMBOL PyObject*
102+
# else /* __cplusplus */
103+
# define PyMODINIT_FUNC Py_EXPORTED_SYMBOL PyObject*
104+
# endif /* __cplusplus */
105+
#endif
106+
107+
36108
#endif /* Py_EXPORTS_H */

Include/fileutils.h

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,41 @@
11
#ifndef Py_FILEUTILS_H
22
#define Py_FILEUTILS_H
3+
4+
/*******************************
5+
* stat() and fstat() fiddling *
6+
*******************************/
7+
8+
#ifdef HAVE_SYS_STAT_H
9+
# include <sys/stat.h> // S_ISREG()
10+
#elif defined(HAVE_STAT_H)
11+
# include <stat.h> // S_ISREG()
12+
#endif
13+
14+
#ifndef S_IFMT
15+
// VisualAge C/C++ Failed to Define MountType Field in sys/stat.h.
16+
# define S_IFMT 0170000
17+
#endif
18+
#ifndef S_IFLNK
19+
// Windows doesn't define S_IFLNK, but posixmodule.c maps
20+
// IO_REPARSE_TAG_SYMLINK to S_IFLNK.
21+
# define S_IFLNK 0120000
22+
#endif
23+
#ifndef S_ISREG
24+
# define S_ISREG(x) (((x) & S_IFMT) == S_IFREG)
25+
#endif
26+
#ifndef S_ISDIR
27+
# define S_ISDIR(x) (((x) & S_IFMT) == S_IFDIR)
28+
#endif
29+
#ifndef S_ISCHR
30+
# define S_ISCHR(x) (((x) & S_IFMT) == S_IFCHR)
31+
#endif
32+
#ifndef S_ISLNK
33+
# define S_ISLNK(x) (((x) & S_IFMT) == S_IFLNK)
34+
#endif
35+
36+
37+
// Move this down here since some C++ #include's don't like to be included
38+
// inside an extern "C".
339
#ifdef __cplusplus
440
extern "C" {
541
#endif

Include/pyport.h

Lines changed: 0 additions & 146 deletions
Original file line numberDiff line numberDiff line change
@@ -184,43 +184,6 @@ typedef Py_ssize_t Py_ssize_clean_t;
184184
# define Py_MEMCPY memcpy
185185
#endif
186186

187-
/*******************************
188-
* stat() and fstat() fiddling *
189-
*******************************/
190-
191-
#ifdef HAVE_SYS_STAT_H
192-
#include <sys/stat.h>
193-
#elif defined(HAVE_STAT_H)
194-
#include <stat.h>
195-
#endif
196-
197-
#ifndef S_IFMT
198-
/* VisualAge C/C++ Failed to Define MountType Field in sys/stat.h */
199-
#define S_IFMT 0170000
200-
#endif
201-
202-
#ifndef S_IFLNK
203-
/* Windows doesn't define S_IFLNK but posixmodule.c maps
204-
* IO_REPARSE_TAG_SYMLINK to S_IFLNK */
205-
# define S_IFLNK 0120000
206-
#endif
207-
208-
#ifndef S_ISREG
209-
#define S_ISREG(x) (((x) & S_IFMT) == S_IFREG)
210-
#endif
211-
212-
#ifndef S_ISDIR
213-
#define S_ISDIR(x) (((x) & S_IFMT) == S_IFDIR)
214-
#endif
215-
216-
#ifndef S_ISCHR
217-
#define S_ISCHR(x) (((x) & S_IFMT) == S_IFCHR)
218-
#endif
219-
220-
#ifndef S_ISLNK
221-
#define S_ISLNK(x) (((x) & S_IFMT) == S_IFLNK)
222-
#endif
223-
224187
#ifdef __cplusplus
225188
/* Move this down here since some C++ #include's don't like to be included
226189
inside an extern "C" */
@@ -392,117 +355,8 @@ extern "C" {
392355
# define Py_NO_INLINE
393356
#endif
394357

395-
/* On 4.4BSD-descendants, ctype functions serves the whole range of
396-
* wchar_t character set rather than single byte code points only.
397-
* This characteristic can break some operations of string object
398-
* including str.upper() and str.split() on UTF-8 locales. This
399-
* workaround was provided by Tim Robbins of FreeBSD project.
400-
*/
401-
402-
#if defined(__APPLE__)
403-
# define _PY_PORT_CTYPE_UTF8_ISSUE
404-
#endif
405-
406-
#ifdef _PY_PORT_CTYPE_UTF8_ISSUE
407-
#ifndef __cplusplus
408-
/* The workaround below is unsafe in C++ because
409-
* the <locale> defines these symbols as real functions,
410-
* with a slightly different signature.
411-
* See issue #10910
412-
*/
413-
#include <ctype.h>
414-
#include <wctype.h>
415-
#undef isalnum
416-
#define isalnum(c) iswalnum(btowc(c))
417-
#undef isalpha
418-
#define isalpha(c) iswalpha(btowc(c))
419-
#undef islower
420-
#define islower(c) iswlower(btowc(c))
421-
#undef isspace
422-
#define isspace(c) iswspace(btowc(c))
423-
#undef isupper
424-
#define isupper(c) iswupper(btowc(c))
425-
#undef tolower
426-
#define tolower(c) towlower(btowc(c))
427-
#undef toupper
428-
#define toupper(c) towupper(btowc(c))
429-
#endif
430-
#endif
431-
432-
433-
/* Declarations for symbol visibility.
434-
435-
PyAPI_FUNC(type): Declares a public Python API function and return type
436-
PyAPI_DATA(type): Declares public Python data and its type
437-
PyMODINIT_FUNC: A Python module init function. If these functions are
438-
inside the Python core, they are private to the core.
439-
If in an extension module, it may be declared with
440-
external linkage depending on the platform.
441-
442-
As a number of platforms support/require "__declspec(dllimport/dllexport)",
443-
we support a HAVE_DECLSPEC_DLL macro to save duplication.
444-
*/
445-
446-
/*
447-
All windows ports, except cygwin, are handled in PC/pyconfig.h.
448-
449-
Cygwin is the only other autoconf platform requiring special
450-
linkage handling and it uses __declspec().
451-
*/
452-
#if defined(__CYGWIN__)
453-
# define HAVE_DECLSPEC_DLL
454-
#endif
455-
456358
#include "exports.h"
457359

458-
/* only get special linkage if built as shared or platform is Cygwin */
459-
#if defined(Py_ENABLE_SHARED) || defined(__CYGWIN__)
460-
# if defined(HAVE_DECLSPEC_DLL)
461-
# if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
462-
# define PyAPI_FUNC(RTYPE) Py_EXPORTED_SYMBOL RTYPE
463-
# define PyAPI_DATA(RTYPE) extern Py_EXPORTED_SYMBOL RTYPE
464-
/* module init functions inside the core need no external linkage */
465-
/* except for Cygwin to handle embedding */
466-
# if defined(__CYGWIN__)
467-
# define PyMODINIT_FUNC Py_EXPORTED_SYMBOL PyObject*
468-
# else /* __CYGWIN__ */
469-
# define PyMODINIT_FUNC PyObject*
470-
# endif /* __CYGWIN__ */
471-
# else /* Py_BUILD_CORE */
472-
/* Building an extension module, or an embedded situation */
473-
/* public Python functions and data are imported */
474-
/* Under Cygwin, auto-import functions to prevent compilation */
475-
/* failures similar to those described at the bottom of 4.1: */
476-
/* http://docs.python.org/extending/windows.html#a-cookbook-approach */
477-
# if !defined(__CYGWIN__)
478-
# define PyAPI_FUNC(RTYPE) Py_IMPORTED_SYMBOL RTYPE
479-
# endif /* !__CYGWIN__ */
480-
# define PyAPI_DATA(RTYPE) extern Py_IMPORTED_SYMBOL RTYPE
481-
/* module init functions outside the core must be exported */
482-
# if defined(__cplusplus)
483-
# define PyMODINIT_FUNC extern "C" Py_EXPORTED_SYMBOL PyObject*
484-
# else /* __cplusplus */
485-
# define PyMODINIT_FUNC Py_EXPORTED_SYMBOL PyObject*
486-
# endif /* __cplusplus */
487-
# endif /* Py_BUILD_CORE */
488-
# endif /* HAVE_DECLSPEC_DLL */
489-
#endif /* Py_ENABLE_SHARED */
490-
491-
/* If no external linkage macros defined by now, create defaults */
492-
#ifndef PyAPI_FUNC
493-
# define PyAPI_FUNC(RTYPE) Py_EXPORTED_SYMBOL RTYPE
494-
#endif
495-
#ifndef PyAPI_DATA
496-
# define PyAPI_DATA(RTYPE) extern Py_EXPORTED_SYMBOL RTYPE
497-
#endif
498-
#ifndef PyMODINIT_FUNC
499-
# if defined(__cplusplus)
500-
# define PyMODINIT_FUNC extern "C" Py_EXPORTED_SYMBOL PyObject*
501-
# else /* __cplusplus */
502-
# define PyMODINIT_FUNC Py_EXPORTED_SYMBOL PyObject*
503-
# endif /* __cplusplus */
504-
#endif
505-
506360
/* limits.h constants that may be missing */
507361

508362
#ifndef INT_MAX

Lib/test/bisect_cmd.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,10 @@ def parse_args():
109109

110110
def main():
111111
args = parse_args()
112-
if '-w' in args.test_args or '--verbose2' in args.test_args:
113-
print("WARNING: -w/--verbose2 option should not be used to bisect!")
114-
print()
112+
for opt in ('-w', '--rerun', '--verbose2'):
113+
if opt in args.test_args:
114+
print(f"WARNING: {opt} option should not be used to bisect!")
115+
print()
115116

116117
if args.input:
117118
with open(args.input) as fp:

Lib/test/libregrtest/cmdline.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ def __init__(self, **kwargs) -> None:
156156
self.coverdir = 'coverage'
157157
self.runleaks = False
158158
self.huntrleaks = False
159-
self.verbose2 = False
159+
self.rerun = False
160160
self.verbose3 = False
161161
self.print_slow = False
162162
self.random_seed = None
@@ -213,8 +213,10 @@ def _create_parser():
213213
group = parser.add_argument_group('Verbosity')
214214
group.add_argument('-v', '--verbose', action='count',
215215
help='run tests in verbose mode with output to stdout')
216-
group.add_argument('-w', '--verbose2', action='store_true',
216+
group.add_argument('-w', '--rerun', action='store_true',
217217
help='re-run failed tests in verbose mode')
218+
group.add_argument('--verbose2', action='store_true', dest='rerun',
219+
help='deprecated alias to --rerun')
218220
group.add_argument('-W', '--verbose3', action='store_true',
219221
help='display test output on failure')
220222
group.add_argument('-q', '--quiet', action='store_true',
@@ -309,6 +311,9 @@ def _create_parser():
309311
group.add_argument('--fail-env-changed', action='store_true',
310312
help='if a test file alters the environment, mark '
311313
'the test as failed')
314+
group.add_argument('--fail-rerun', action='store_true',
315+
help='if a test failed and then passed when re-run, '
316+
'mark the tests as failed')
312317

313318
group.add_argument('--junit-xml', dest='xmlpath', metavar='FILENAME',
314319
help='writes JUnit-style XML results to the specified '
@@ -380,7 +385,7 @@ def _parse_args(args, **kwargs):
380385
ns.python = shlex.split(ns.python)
381386
if ns.failfast and not (ns.verbose or ns.verbose3):
382387
parser.error("-G/--failfast needs either -v or -W")
383-
if ns.pgo and (ns.verbose or ns.verbose2 or ns.verbose3):
388+
if ns.pgo and (ns.verbose or ns.rerun or ns.verbose3):
384389
parser.error("--pgo/-v don't go together!")
385390
if ns.pgo_extended:
386391
ns.pgo = True # pgo_extended implies pgo

0 commit comments

Comments
 (0)