Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -586,10 +586,10 @@ Lib/test/test_string/test_templatelib.py @lysnikolaou @AA-Turner
**/*sysconfig* @FFY00

# SQLite 3
Doc/library/sqlite3.rst @berkerpeksag @erlend-aasland
Lib/sqlite3/ @berkerpeksag @erlend-aasland
Lib/test/test_sqlite3/ @berkerpeksag @erlend-aasland
Modules/_sqlite/ @berkerpeksag @erlend-aasland
Doc/library/sqlite3.rst @erlend-aasland
Lib/sqlite3/ @erlend-aasland
Lib/test/test_sqlite3/ @erlend-aasland
Modules/_sqlite/ @erlend-aasland

# Subprocess
Lib/subprocess.py @gpshead
Expand Down Expand Up @@ -622,9 +622,6 @@ Modules/_typesmodule.c @AA-Turner
Lib/unittest/mock.py @cjw296
Lib/test/test_unittest/testmock/ @cjw296

# Urllib
**/*robotparser* @berkerpeksag

# Venv
**/*venv* @vsajip @FFY00

Expand Down
2 changes: 1 addition & 1 deletion Doc/deprecations/pending-removal-in-3.16.rst
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ Pending removal in Python 3.16

* :mod:`sys`:

* The :func:`~sys._enablelegacywindowsfsencoding` function
* The :func:`!_enablelegacywindowsfsencoding` function
has been deprecated since Python 3.13.
Use the :envvar:`PYTHONLEGACYWINDOWSFSENCODING` environment variable instead.

Expand Down
8 changes: 8 additions & 0 deletions Doc/library/mimetypes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,18 @@ behavior of the module.
Add a mapping from the MIME type *type* to the extension *ext*. When the
extension is already known, the new type will replace the old one. When the type
is already known the extension will be added to the list of known extensions.
Valid extensions are empty or start with a ``'.'``.

When *strict* is ``True`` (the default), the mapping will be added to the
official MIME types, otherwise to the non-standard ones.

.. deprecated:: 3.14
*ext* values that do not start with ``'.'`` are deprecated.

.. versionchanged:: next
*ext* now must start with ``'.'``. Otherwise :exc:`ValueError` is raised.



.. data:: inited

Expand Down
27 changes: 1 addition & 26 deletions Doc/library/sys.rst
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,7 @@ always available. Unless explicitly noted otherwise, all variables are read-only

.. versionchanged:: 3.6
Windows is no longer guaranteed to return ``'mbcs'``. See :pep:`529`
and :func:`_enablelegacywindowsfsencoding` for more information.
for more information.

.. versionchanged:: 3.7
Return ``'utf-8'`` if the :ref:`Python UTF-8 Mode <utf8-mode>` is
Expand Down Expand Up @@ -2107,31 +2107,6 @@ always available. Unless explicitly noted otherwise, all variables are read-only
See :pep:`768` for more details.


.. function:: _enablelegacywindowsfsencoding()

Changes the :term:`filesystem encoding and error handler` to 'mbcs' and
'replace' respectively, for consistency with versions of Python prior to
3.6.

This is equivalent to defining the :envvar:`PYTHONLEGACYWINDOWSFSENCODING`
environment variable before launching Python.

See also :func:`sys.getfilesystemencoding` and
:func:`sys.getfilesystemencodeerrors`.

.. availability:: Windows.

.. note::
Changing the filesystem encoding after Python startup is risky because
the old fsencoding or paths encoded by the old fsencoding may be cached
somewhere. Use :envvar:`PYTHONLEGACYWINDOWSFSENCODING` instead.

.. versionadded:: 3.6
See :pep:`529` for more details.

.. deprecated-removed:: 3.13 3.16
Use :envvar:`PYTHONLEGACYWINDOWSFSENCODING` instead.

.. data:: stdin
stdout
stderr
Expand Down
3 changes: 2 additions & 1 deletion Doc/tools/removed-ids.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ c-api/file.html: deprecated-api
library/asyncio-task.html: terminating-a-task-group

# Removed APIs
library/symtable.html: symtable.Class.get_methods
library/symtable.html: symtable.Class.get_methods
library/sys.html: sys._enablelegacywindowsfsencoding
3 changes: 0 additions & 3 deletions Doc/using/cmdline.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1154,9 +1154,6 @@ conflict.
'replace', respectively. Otherwise, the new defaults 'utf-8' and
'surrogatepass' are used.

This may also be enabled at runtime with
:func:`sys._enablelegacywindowsfsencoding`.

.. availability:: Windows.

.. versionadded:: 3.6
Expand Down
2 changes: 1 addition & 1 deletion Doc/whatsnew/3.13.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1958,7 +1958,7 @@ New Deprecations

* :mod:`sys`:

* Deprecate the :func:`~sys._enablelegacywindowsfsencoding` function,
* Deprecate the :func:`!_enablelegacywindowsfsencoding` function,
to be removed in Python 3.16.
Use the :envvar:`PYTHONLEGACYWINDOWSFSENCODING` environment variable instead.
(Contributed by Inada Naoki in :gh:`73427`.)
Expand Down
15 changes: 15 additions & 0 deletions Doc/whatsnew/3.16.rst
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,27 @@ logging
and scheduled for removal in Python 3.16. Define handlers with the *stream*
argument instead.

mimetypes
---------

* Valid extensions start with a '.' or are empty for
:meth:`mimetypes.MimeTypes.add_type`.
Undotted extensions now raise a :exc:`ValueError`.

symtable
--------

* The :meth:`!symtable.Class.get_methods` method
which has been deprecated since Python 3.14.

sys
---

* The :func:`!_enablelegacywindowsfsencoding` function
which has been deprecated since Python 3.13.
Use the :envvar:`PYTHONLEGACYWINDOWSFSENCODING` environment variable instead.
(Contributed by Stan Ulbrych in :gh:`149595`.)

sysconfig
---------

Expand Down
2 changes: 1 addition & 1 deletion Doc/whatsnew/3.6.rst
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ Applications that do not use str to represent paths should use
:func:`os.fsencode` and :func:`os.fsdecode` to ensure their bytes are
correctly encoded. To revert to the previous behaviour, set
:envvar:`PYTHONLEGACYWINDOWSFSENCODING` or call
:func:`sys._enablelegacywindowsfsencoding`.
:func:`!sys._enablelegacywindowsfsencoding`.

See :pep:`529` for more information and discussion of code modifications that
may be required.
Expand Down
3 changes: 0 additions & 3 deletions Include/internal/pycore_pylifecycle.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ extern int _Py_SetFileSystemEncoding(
const char *errors);
extern void _Py_ClearFileSystemEncoding(void);
extern PyStatus _PyUnicode_InitEncodings(PyThreadState *tstate);
#ifdef MS_WINDOWS
extern int _PyUnicode_EnableLegacyWindowsFSEncoding(void);
#endif

extern int _Py_IsLocaleCoercionTarget(const char *ctype_loc);

Expand Down
9 changes: 1 addition & 8 deletions Lib/mimetypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,7 @@ def add_type(self, type, ext, strict=True):
Valid extensions are empty or start with a '.'.
"""
if ext and not ext.startswith('.'):
from warnings import _deprecated

_deprecated(
"Undotted extensions",
"Using undotted extensions is deprecated and "
"will raise a ValueError in Python {remove}",
remove=(3, 16),
)
raise ValueError(f"Extension {ext!r} must start with '.'")

if not type:
return
Expand Down
7 changes: 5 additions & 2 deletions Lib/test/test_mimetypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,9 +389,12 @@ def test_added_types_are_used(self):
mime_type, _ = mimetypes.guess_type('test.myext')
self.assertEqual(mime_type, 'testing/type')

def test_add_type_with_undotted_extension_deprecated(self):
with self.assertWarns(DeprecationWarning):
def test_add_type_with_undotted_extension_not_supported(self):
msg = "Extension 'undotted' must start with '.'"
with self.assertRaisesRegex(ValueError, msg):
mimetypes.add_type("testing/type", "undotted")
with self.assertRaisesRegex(ValueError, msg):
mimetypes.add_type("", "undotted")


@unittest.skipUnless(sys.platform.startswith("win"), "Windows only")
Expand Down
10 changes: 0 additions & 10 deletions Lib/test/test_sys.py
Original file line number Diff line number Diff line change
Expand Up @@ -1283,16 +1283,6 @@ def check(tracebacklimit, expected):
def test_no_duplicates_in_meta_path(self):
self.assertEqual(len(sys.meta_path), len(set(sys.meta_path)))

@unittest.skipUnless(hasattr(sys, "_enablelegacywindowsfsencoding"),
'needs sys._enablelegacywindowsfsencoding()')
def test__enablelegacywindowsfsencoding(self):
code = ('import sys',
'sys._enablelegacywindowsfsencoding()',
'print(sys.getfilesystemencoding(), sys.getfilesystemencodeerrors())')
rc, out, err = assert_python_ok('-c', '; '.join(code))
out = out.decode('ascii', 'replace').rstrip()
self.assertEqual(out, 'mbcs replace')

@support.requires_subprocess()
def test_orig_argv(self):
code = textwrap.dedent('''
Expand Down
2 changes: 1 addition & 1 deletion Misc/NEWS.d/3.13.0a3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2166,7 +2166,7 @@ current user has no permission to the WMI.
.. nonce: WOpiNt
.. section: Windows

Deprecate :func:`sys._enablelegacywindowsfsencoding`. Use
Deprecate :func:`!sys._enablelegacywindowsfsencoding`. Use
:envvar:`PYTHONLEGACYWINDOWSFSENCODING` instead. Patch by Inada Naoki.

..
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Add branch protections for AArch64 (BTI/PAC) in assembly code used by
:option:`-X perf_jit <-X>` (Linux perf profiler integration).
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Remove the :func:`!sys._enablelegacywindowsfsencoding` function which has
been deprecated since Python 3.13.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove support for undotted *ext* in :meth:`mimetypes.MimeTypes.add_type`.
10 changes: 6 additions & 4 deletions Modules/_testinternalcapi/test_cases.c.h

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

27 changes: 0 additions & 27 deletions Objects/unicodeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -14928,33 +14928,6 @@ _PyUnicode_FiniEncodings(struct _Py_unicode_fs_codec *fs_codec)
}


#ifdef MS_WINDOWS
int
_PyUnicode_EnableLegacyWindowsFSEncoding(void)
{
PyInterpreterState *interp = _PyInterpreterState_GET();
PyConfig *config = (PyConfig *)_PyInterpreterState_GetConfig(interp);

/* Set the filesystem encoding to mbcs/replace (PEP 529) */
wchar_t *encoding = _PyMem_RawWcsdup(L"mbcs");
wchar_t *errors = _PyMem_RawWcsdup(L"replace");
if (encoding == NULL || errors == NULL) {
PyMem_RawFree(encoding);
PyMem_RawFree(errors);
PyErr_NoMemory();
return -1;
}

PyMem_RawFree(config->filesystem_encoding);
config->filesystem_encoding = encoding;
PyMem_RawFree(config->filesystem_errors);
config->filesystem_errors = errors;

return init_fs_codec(interp);
}
#endif


#ifdef Py_DEBUG
static inline int
unicode_is_finalizing(void)
Expand Down
4 changes: 4 additions & 0 deletions Python/asm_trampoline.S
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include "asm_trampoline_aarch64.h"

.text
#if defined(__APPLE__)
.globl __Py_trampoline_func_start
Expand Down Expand Up @@ -29,10 +31,12 @@ _Py_trampoline_func_start:
#if defined(__aarch64__) && defined(__AARCH64EL__) && !defined(__ILP32__)
// ARM64 little endian, 64bit ABI
// generate with aarch64-linux-gnu-gcc 12.1
SIGN_LR
stp x29, x30, [sp, -16]!
mov x29, sp
blr x3
ldp x29, x30, [sp], 16
VERIFY_LR
ret
#endif
#ifdef __riscv
Expand Down
56 changes: 56 additions & 0 deletions Python/asm_trampoline_aarch64.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#ifndef ASM_TRAMPOLINE_AARCH_64_H_
#define ASM_TRAMPOLINE_AARCH_64_H_

/*
* References:
* - https://developer.arm.com/documentation/101028/0012/5--Feature-test-macros
* - https://github.com/ARM-software/abi-aa/blob/main/aaelf64/aaelf64.rst
*/

#if defined(__ARM_FEATURE_BTI_DEFAULT) && __ARM_FEATURE_BTI_DEFAULT == 1
#define BTI_J hint 36 /* bti j: for jumps, IE br instructions */
#define BTI_C hint 34 /* bti c: for calls, IE bl instructions */
#define GNU_PROPERTY_AARCH64_BTI 1 /* bit 0 GNU Notes is for BTI support */
#else
#define BTI_J
#define BTI_C
#define GNU_PROPERTY_AARCH64_BTI 0
#endif

#if defined(__ARM_FEATURE_PAC_DEFAULT)
#if __ARM_FEATURE_PAC_DEFAULT & 1
#define SIGN_LR hint 25 /* paciasp: sign with the A key */
#define VERIFY_LR hint 29 /* autiasp: verify with the A key */
#elif __ARM_FEATURE_PAC_DEFAULT & 2
#define SIGN_LR hint 27 /* pacibsp: sign with the b key */
#define VERIFY_LR hint 31 /* autibsp: verify with the b key */
#endif
#define GNU_PROPERTY_AARCH64_POINTER_AUTH 2 /* bit 1 GNU Notes is for PAC support */
#else
#define SIGN_LR BTI_C
#define VERIFY_LR
#define GNU_PROPERTY_AARCH64_POINTER_AUTH 0
#endif

#if defined(__ARM_FEATURE_GCS_DEFAULT) && __ARM_FEATURE_GCS_DEFAULT == 1
#define GNU_PROPERTY_AARCH64_GCS 4 /* bit 2 GNU Notes is for GCS support */
#else
#define GNU_PROPERTY_AARCH64_GCS 0
#endif

/* Add the BTI, PAC and GCS support to GNU Notes section */
#if GNU_PROPERTY_AARCH64_BTI != 0 || GNU_PROPERTY_AARCH64_POINTER_AUTH != 0 || GNU_PROPERTY_AARCH64_GCS != 0
.pushsection .note.gnu.property, "a"; /* Start a new allocatable section */
.balign 8; /* align it on a byte boundry */
.long 4; /* size of "GNU\0" */
.long 0x10; /* size of descriptor */
.long 0x5; /* NT_GNU_PROPERTY_TYPE_0 */
.asciz "GNU";
.long 0xc0000000; /* GNU_PROPERTY_AARCH64_FEATURE_1_AND */
.long 4; /* Four bytes of data */
.long (GNU_PROPERTY_AARCH64_BTI|GNU_PROPERTY_AARCH64_POINTER_AUTH|GNU_PROPERTY_AARCH64_GCS); /* BTI, PAC or GCS is enabled */
.long 0; /* padding for 8 byte alignment */
.popsection; /* end the section */
#endif

#endif
5 changes: 3 additions & 2 deletions Python/bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -1867,8 +1867,9 @@ dummy_func(
assert(INLINE_CACHE_ENTRIES_SEND == INLINE_CACHE_ENTRIES_FOR_ITER);
#if TIER_ONE && defined(Py_DEBUG)
if (!PyStackRef_IsNone(frame->f_executable)) {
int i = frame->instr_ptr - _PyFrame_GetBytecode(frame);
int opcode = _Py_GetBaseCodeUnit(_PyFrame_GetCode(frame), i).op.code;
Py_ssize_t i = frame->instr_ptr - _PyFrame_GetBytecode(frame);
assert(i >= 0 && i <= INT_MAX);
int opcode = _Py_GetBaseCodeUnit(_PyFrame_GetCode(frame), (int)i).op.code;
assert(opcode == SEND || opcode == FOR_ITER);
}
#endif
Expand Down
Loading
Loading