Skip to content
4 changes: 2 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
root = true

[*.{py,c,cpp,h,js,rst,md,yml,yaml}]
[*.{py,c,cpp,h,js,rst,md,yml,yaml,gram}]
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space

[*.{py,c,cpp,h}]
[*.{py,c,cpp,h,gram}]
indent_size = 4

[*.rst]
Expand Down
4 changes: 4 additions & 0 deletions Doc/library/importlib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,10 @@ Functions
:exc:`ModuleNotFoundError` is raised when the module being reloaded lacks
a :class:`~importlib.machinery.ModuleSpec`.

.. warning::
This function is not thread-safe. Calling it from multiple threads can result
in unexpected behavior. It's recommended to use the :class:`threading.Lock`
or other synchronization primitives for thread-safe module reloading.

:mod:`importlib.abc` -- Abstract base classes related to import
---------------------------------------------------------------
Expand Down
8 changes: 4 additions & 4 deletions Doc/library/venv.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ The :mod:`!venv` module supports creating lightweight "virtual environments",
each with their own independent set of Python packages installed in
their :mod:`site` directories.
A virtual environment is created on top of an existing
Python installation, known as the virtual environment's "base" Python, and may
optionally be isolated from the packages in the base environment,
so only those explicitly installed in the virtual environment are available.
See :ref:`sys-path-init-virtual-environments` and :mod:`site`'s
Python installation, known as the virtual environment's "base" Python, and by
default is isolated from the packages in the base environment,
so that only those explicitly installed in the virtual environment are
available. See :ref:`sys-path-init-virtual-environments` and :mod:`site`'s
:ref:`virtual environments documentation <site-virtual-environments-configuration>`
for more information.

Expand Down
2 changes: 1 addition & 1 deletion Lib/test/support/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ def skip_android_selinux(name):
is_wasi = sys.platform == "wasi"

def skip_emscripten_stack_overflow():
return unittest.skipIf(is_emscripten, "Exhausts limited stack on Emscripten")
return unittest.skipIf(is_emscripten, "Exhausts stack on Emscripten")

def skip_wasi_stack_overflow():
return unittest.skipIf(is_wasi, "Exhausts stack on WASI")
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_descr.py
Original file line number Diff line number Diff line change
Expand Up @@ -3942,7 +3942,7 @@ def __del__(self):
# it as a leak.
del C.__del__

@unittest.skipIf(support.is_emscripten, "Seems to works in Pyodide?")
@support.skip_emscripten_stack_overflow()
@support.skip_wasi_stack_overflow()
def test_slots_trash(self):
# Testing slot trash...
Expand Down
6 changes: 2 additions & 4 deletions Lib/test/test_os.py
Original file line number Diff line number Diff line change
Expand Up @@ -1918,11 +1918,9 @@ def test_makedir(self):
support.is_wasi,
"WASI's umask is a stub."
)
@unittest.skipIf(
support.is_emscripten,
"TODO: Fails in buildbot; see #135783"
)
def test_mode(self):
# Note: in some cases, the umask might already be 2 in which case this
# will pass even if os.umask is actually broken.
with os_helper.temp_umask(0o002):
base = os_helper.TESTFN
parent = os.path.join(base, 'dir1')
Expand Down
8 changes: 1 addition & 7 deletions Lib/test/test_warnings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,13 +555,7 @@ def test_warn_explicit_non_ascii_filename(self):
with self.module.catch_warnings(record=True) as w:
self.module.resetwarnings()
self.module.filterwarnings("always", category=UserWarning)
filenames = ["nonascii\xe9\u20ac"]
if not support.is_emscripten:
# JavaScript does not like surrogates.
# Invalid UTF-8 leading byte 0x80 encountered when
# deserializing a UTF-8 string in wasm memory to a JS
# string!
filenames.append("surrogate\udc80")
filenames = ["nonascii\xe9\u20ac", "surrogate\udc80"]
for filename in filenames:
try:
os.fsencode(filename)
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_xml_etree_c.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def test_del_attribute(self):
self.assertEqual(element.attrib, {'A': 'B', 'C': 'D'})

@support.skip_wasi_stack_overflow()
@unittest.skipIf(support.is_emscripten, "segfaults")
@support.skip_emscripten_stack_overflow()
def test_trashcan(self):
# If this test fails, it will most likely die via segfault.
e = root = cET.Element('root')
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
:mod:`!_asyncio` is now statically linked for improved performance.
7 changes: 6 additions & 1 deletion Modules/Setup.stdlib.in
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
############################################################################
# Modules that should always be present (POSIX and Windows):
@MODULE_ARRAY_TRUE@array arraymodule.c
@MODULE__ASYNCIO_TRUE@_asyncio _asynciomodule.c
@MODULE__BISECT_TRUE@_bisect _bisectmodule.c
@MODULE__CSV_TRUE@_csv _csv.c
@MODULE__HEAPQ_TRUE@_heapq _heapqmodule.c
Expand Down Expand Up @@ -193,3 +192,9 @@
# Limited API template modules; must be built as shared modules.
@MODULE_XXLIMITED_TRUE@xxlimited xxlimited.c
@MODULE_XXLIMITED_35_TRUE@xxlimited_35 xxlimited_35.c


# for performance
*static*

@MODULE__ASYNCIO_TRUE@_asyncio _asynciomodule.c
6 changes: 3 additions & 3 deletions Modules/_remote_debugging_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,7 @@ _Py_RemoteDebug_GetAsyncioDebugAddress(proc_handle_t* handle)
}
#elif defined(__linux__)
// On Linux, search for asyncio debug in executable or DLL
address = search_linux_map_for_section(handle, "AsyncioDebug", "_asyncio.cpython");
address = search_linux_map_for_section(handle, "AsyncioDebug", "python");
if (address == 0) {
// Error out: 'python' substring covers both executable and DLL
PyObject *exc = PyErr_GetRaisedException();
Expand All @@ -820,10 +820,10 @@ _Py_RemoteDebug_GetAsyncioDebugAddress(proc_handle_t* handle)
}
#elif defined(__APPLE__) && TARGET_OS_OSX
// On macOS, try libpython first, then fall back to python
address = search_map_for_section(handle, "AsyncioDebug", "_asyncio.cpython");
address = search_map_for_section(handle, "AsyncioDebug", "libpython");
if (address == 0) {
PyErr_Clear();
address = search_map_for_section(handle, "AsyncioDebug", "_asyncio.cpython");
address = search_map_for_section(handle, "AsyncioDebug", "python");
}
if (address == 0) {
// Error out: 'python' substring covers both executable and DLL
Expand Down
4 changes: 2 additions & 2 deletions Modules/clinic/posixmodule.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Modules/posixmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -3477,12 +3477,12 @@ Change the current working directory to the specified path.

path may always be specified as a string.
On some platforms, path may also be specified as an open file descriptor.
If this functionality is unavailable, using it raises an exception.
If this functionality is unavailable, using it raises an exception.
[clinic start generated code]*/

static PyObject *
os_chdir_impl(PyObject *module, path_t *path)
/*[clinic end generated code: output=3be6400eee26eaae input=1a4a15b4d12cb15d]*/
/*[clinic end generated code: output=3be6400eee26eaae input=a74ceab5d72adf74]*/
{
int result;

Expand Down
22 changes: 21 additions & 1 deletion Python/emscripten_syscalls.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// defined with weak linkage so we can override it.
EM_JS(int, __syscall_getuid32_js, (void), {
// If we're in node and we can, report the native uid
if (typeof process !== "undefined" && typeof process.getuid === "function") {
if (ENVIRONMENT_IS_NODE) {
return process.getuid();
}
// Fall back to the stub case of returning 0.
Expand All @@ -17,3 +17,23 @@ EM_JS(int, __syscall_getuid32_js, (void), {
int __syscall_getuid32(void) {
return __syscall_getuid32_js();
}

EM_JS(int, __syscall_umask_js, (int mask), {
// If we're in node and we can, call native process.umask()
if (ENVIRONMENT_IS_NODE) {
try {
return process.umask(mask);
} catch(e) {
// oops...
// NodeJS docs: "In Worker threads, process.umask(mask) will throw an exception."
// umask docs: "This system call always succeeds"
return 0;
}
}
// Fall back to the stub case of returning 0.
return 0;
})

int __syscall_umask(int mask) {
return __syscall_umask_js(mask);
}
Loading