Skip to content

Commit aef2b2d

Browse files
committed
Merge branch 'main' into gh-129027
2 parents fc4d384 + 8ceb6cb commit aef2b2d

File tree

127 files changed

+3393
-3651
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+3393
-3651
lines changed

Doc/c-api/init_config.rst

Lines changed: 1555 additions & 1301 deletions
Large diffs are not rendered by default.

Doc/whatsnew/3.14.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1375,3 +1375,7 @@ Removed
13751375

13761376
* Creating :c:data:`immutable types <Py_TPFLAGS_IMMUTABLETYPE>` with mutable
13771377
bases was deprecated since 3.12 and now raises a :exc:`TypeError`.
1378+
1379+
* Remove the private ``_Py_InitializeMain()`` function. It was a
1380+
:term:`provisional API` added to Python 3.8 by :pep:`587`.
1381+
(Contributed by Victor Stinner in :gh:`129033`.)

Include/cpython/pylifecycle.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@ PyAPI_FUNC(PyStatus) Py_PreInitializeFromArgs(
2525
PyAPI_FUNC(PyStatus) Py_InitializeFromConfig(
2626
const PyConfig *config);
2727

28-
// Python 3.8 provisional API (PEP 587)
29-
PyAPI_FUNC(PyStatus) _Py_InitializeMain(void);
30-
3128
PyAPI_FUNC(int) Py_RunMain(void);
3229

3330

Include/internal/pycore_interp.h

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -341,43 +341,6 @@ extern void _PyInterpreterState_SetWhence(
341341

342342
extern const PyConfig* _PyInterpreterState_GetConfig(PyInterpreterState *interp);
343343

344-
// Get a copy of the current interpreter configuration.
345-
//
346-
// Return 0 on success. Raise an exception and return -1 on error.
347-
//
348-
// The caller must initialize 'config', using PyConfig_InitPythonConfig()
349-
// for example.
350-
//
351-
// Python must be preinitialized to call this method.
352-
// The caller must hold the GIL.
353-
//
354-
// Once done with the configuration, PyConfig_Clear() must be called to clear
355-
// it.
356-
//
357-
// Export for '_testinternalcapi' shared extension.
358-
PyAPI_FUNC(int) _PyInterpreterState_GetConfigCopy(
359-
struct PyConfig *config);
360-
361-
// Set the configuration of the current interpreter.
362-
//
363-
// This function should be called during or just after the Python
364-
// initialization.
365-
//
366-
// Update the sys module with the new configuration. If the sys module was
367-
// modified directly after the Python initialization, these changes are lost.
368-
//
369-
// Some configuration like faulthandler or warnoptions can be updated in the
370-
// configuration, but don't reconfigure Python (don't enable/disable
371-
// faulthandler and don't reconfigure warnings filters).
372-
//
373-
// Return 0 on success. Raise an exception and return -1 on error.
374-
//
375-
// The configuration should come from _PyInterpreterState_GetConfigCopy().
376-
//
377-
// Export for '_testinternalcapi' shared extension.
378-
PyAPI_FUNC(int) _PyInterpreterState_SetConfig(
379-
const struct PyConfig *config);
380-
381344

382345
/*
383346
Runtime Feature Flags

Include/internal/pycore_pystate.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,19 @@ PyAPI_FUNC(const PyConfig*) _Py_GetConfig(void);
300300
// See also PyInterpreterState_Get() and _PyInterpreterState_GET().
301301
extern PyInterpreterState* _PyGILState_GetInterpreterStateUnsafe(void);
302302

303+
#ifndef NDEBUG
304+
/* Modern equivalent of assert(PyGILState_Check()) */
305+
static inline void
306+
_Py_AssertHoldsTstateFunc(const char *func)
307+
{
308+
PyThreadState *tstate = _PyThreadState_GET();
309+
_Py_EnsureFuncTstateNotNULL(func, tstate);
310+
}
311+
#define _Py_AssertHoldsTstate() _Py_AssertHoldsTstateFunc(__func__)
312+
#else
313+
#define _Py_AssertHoldsTstate()
314+
#endif
315+
303316
#ifdef __cplusplus
304317
}
305318
#endif

Lib/_colorize.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,17 @@ class ANSIColors:
2626
setattr(NoColors, attr, "")
2727

2828

29-
def get_colors(colorize: bool = False) -> ANSIColors:
30-
if colorize or can_colorize():
29+
def get_colors(colorize: bool = False, *, file=None) -> ANSIColors:
30+
if colorize or can_colorize(file=file):
3131
return ANSIColors()
3232
else:
3333
return NoColors
3434

3535

36-
def can_colorize() -> bool:
36+
def can_colorize(*, file=None) -> bool:
37+
if file is None:
38+
file = sys.stdout
39+
3740
if not sys.flags.ignore_environment:
3841
if os.environ.get("PYTHON_COLORS") == "0":
3942
return False
@@ -49,7 +52,7 @@ def can_colorize() -> bool:
4952
if os.environ.get("TERM") == "dumb":
5053
return False
5154

52-
if not hasattr(sys.stderr, "fileno"):
55+
if not hasattr(file, "fileno"):
5356
return False
5457

5558
if sys.platform == "win32":
@@ -62,6 +65,6 @@ def can_colorize() -> bool:
6265
return False
6366

6467
try:
65-
return os.isatty(sys.stderr.fileno())
68+
return os.isatty(file.fileno())
6669
except io.UnsupportedOperation:
67-
return sys.stderr.isatty()
70+
return file.isatty()

Lib/doctest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1558,7 +1558,7 @@ def out(s):
15581558
save_displayhook = sys.displayhook
15591559
sys.displayhook = sys.__displayhook__
15601560
saved_can_colorize = _colorize.can_colorize
1561-
_colorize.can_colorize = lambda: False
1561+
_colorize.can_colorize = lambda *args, **kwargs: False
15621562
color_variables = {"PYTHON_COLORS": None, "FORCE_COLOR": None}
15631563
for key in color_variables:
15641564
color_variables[key] = os.environ.pop(key, None)

Lib/sysconfig/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,9 @@ def expand_makefile_vars(s, vars):
718718
"""
719719
import re
720720

721+
_findvar1_rx = r"\$\(([A-Za-z][A-Za-z0-9_]*)\)"
722+
_findvar2_rx = r"\${([A-Za-z][A-Za-z0-9_]*)}"
723+
721724
# This algorithm does multiple expansion, so if vars['foo'] contains
722725
# "${bar}", it will expand ${foo} to ${bar}, and then expand
723726
# ${bar}... and so forth. This is fine as long as 'vars' comes from

0 commit comments

Comments
 (0)