Skip to content

Commit b9512c3

Browse files
committed
Merge branch '3.13' of https://github.com/python/cpython into 3.13
2 parents c7ee596 + b679b74 commit b9512c3

File tree

9 files changed

+394
-3
lines changed

9 files changed

+394
-3
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix libc thread safety issues with :mod:`os` by replacing ``getlogin`` with
2+
``getlogin_r`` re-entrant version.

Modules/posixmodule.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9464,6 +9464,24 @@ os_getlogin_impl(PyObject *module)
94649464
}
94659465
else
94669466
result = PyErr_SetFromWindowsErr(GetLastError());
9467+
#elif defined (HAVE_GETLOGIN_R)
9468+
# if defined (HAVE_MAXLOGNAME)
9469+
char name[MAXLOGNAME + 1];
9470+
# elif defined (HAVE_UT_NAMESIZE)
9471+
char name[UT_NAMESIZE + 1];
9472+
# else
9473+
char name[256];
9474+
# endif
9475+
int err = getlogin_r(name, sizeof(name));
9476+
if (err) {
9477+
int old_errno = errno;
9478+
errno = -err;
9479+
posix_error();
9480+
errno = old_errno;
9481+
}
9482+
else {
9483+
result = PyUnicode_DecodeFSDefault(name);
9484+
}
94679485
#else
94689486
char *name;
94699487
int old_errno = errno;

PC/layout/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import sys
22

33
try:
4-
import layout
4+
import layout # noqa: F401
55
except ImportError:
66
# Failed to import our package, which likely means we were started directly
77
# Add the additional search path needed to locate our module.

PC/layout/main.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
__version__ = "3.8"
99

1010
import argparse
11+
import json
1112
import os
1213
import shutil
1314
import sys
@@ -28,6 +29,7 @@
2829
from .support.options import *
2930
from .support.pip import *
3031
from .support.props import *
32+
from .support.pymanager import *
3133
from .support.nuspec import *
3234

3335
TEST_PYDS_ONLY = FileStemSet("xxlimited", "xxlimited_35", "_ctypes_test", "_test*")
@@ -265,7 +267,12 @@ def _c(d):
265267
if ns.include_dev:
266268
for dest, src in rglob(ns.source / "Include", "**/*.h"):
267269
yield "include/{}".format(dest), src
268-
yield "include/pyconfig.h", ns.build / "pyconfig.h"
270+
# Support for layout of new and old releases.
271+
pc = ns.source / "PC"
272+
if (pc / "pyconfig.h.in").is_file():
273+
yield "include/pyconfig.h", ns.build / "pyconfig.h"
274+
else:
275+
yield "include/pyconfig.h", pc / "pyconfig.h"
269276

270277
for dest, src in get_tcltk_lib(ns):
271278
yield dest, src
@@ -303,6 +310,9 @@ def _c(d):
303310
else:
304311
yield "DLLs/{}".format(ns.include_cat.name), ns.include_cat
305312

313+
if ns.include_install_json or ns.include_install_embed_json or ns.include_install_test_json:
314+
yield "__install__.json", ns.temp / "__install__.json"
315+
306316

307317
def _compile_one_py(src, dest, name, optimize, checked=True):
308318
import py_compile
@@ -394,6 +404,22 @@ def generate_source_files(ns):
394404
log_info("Extracting pip")
395405
extract_pip_files(ns)
396406

407+
if ns.include_install_json:
408+
log_info("Generating __install__.json in {}", ns.temp)
409+
ns.temp.mkdir(parents=True, exist_ok=True)
410+
with open(ns.temp / "__install__.json", "w", encoding="utf-8") as f:
411+
json.dump(calculate_install_json(ns), f, indent=2)
412+
elif ns.include_install_embed_json:
413+
log_info("Generating embeddable __install__.json in {}", ns.temp)
414+
ns.temp.mkdir(parents=True, exist_ok=True)
415+
with open(ns.temp / "__install__.json", "w", encoding="utf-8") as f:
416+
json.dump(calculate_install_json(ns, for_embed=True), f, indent=2)
417+
elif ns.include_install_test_json:
418+
log_info("Generating test __install__.json in {}", ns.temp)
419+
ns.temp.mkdir(parents=True, exist_ok=True)
420+
with open(ns.temp / "__install__.json", "w", encoding="utf-8") as f:
421+
json.dump(calculate_install_json(ns, for_test=True), f, indent=2)
422+
397423

398424
def _create_zip_file(ns):
399425
if not ns.zip:
@@ -627,6 +653,7 @@ def main():
627653
if ns.include_cat and not ns.include_cat.is_absolute():
628654
ns.include_cat = (Path.cwd() / ns.include_cat).resolve()
629655
if not ns.arch:
656+
# TODO: Calculate arch from files in ns.build instead
630657
if sys.winver.endswith("-arm64"):
631658
ns.arch = "arm64"
632659
elif sys.winver.endswith("-32"):

PC/layout/support/options.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ def public(f):
3636
"alias": {"help": "aliased python.exe entry-point binaries"},
3737
"alias3": {"help": "aliased python3.exe entry-point binaries"},
3838
"alias3x": {"help": "aliased python3.x.exe entry-point binaries"},
39+
"install-json": {"help": "a PyManager __install__.json file"},
40+
"install-embed-json": {"help": "a PyManager __install__.json file for embeddable distro"},
41+
"install-test-json": {"help": "a PyManager __install__.json for the test distro"},
3942
}
4043

4144

@@ -95,6 +98,34 @@ def public(f):
9598
"precompile",
9699
],
97100
},
101+
"pymanager": {
102+
"help": "PyManager package",
103+
"options": [
104+
"stable",
105+
"pip",
106+
"tcltk",
107+
"idle",
108+
"venv",
109+
"dev",
110+
"html-doc",
111+
"install-json",
112+
],
113+
},
114+
"pymanager-test": {
115+
"help": "PyManager test package",
116+
"options": [
117+
"stable",
118+
"pip",
119+
"tcltk",
120+
"idle",
121+
"venv",
122+
"dev",
123+
"html-doc",
124+
"symbols",
125+
"tests",
126+
"install-test-json",
127+
],
128+
},
98129
}
99130

100131

0 commit comments

Comments
 (0)