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
4 changes: 4 additions & 0 deletions Doc/c-api/memory.rst
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,10 @@ This allocator is disabled if Python is configured with the
:option:`--without-pymalloc` option. It can also be disabled at runtime using
the :envvar:`PYTHONMALLOC` environment variable (ex: ``PYTHONMALLOC=malloc``).

Typically, it makes sense to disable the pymalloc allocator when building
Python with AddressSanitizer (:option:`--with-address-sanitizer`) which helps
uncover low level bugs within the C code.

Customize pymalloc Arena Allocator
----------------------------------

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

* :mod:`pathlib`:

* :meth:`.PurePath.is_reserved`
* :meth:`!.PurePath.is_reserved`
has been deprecated since Python 3.13.
Use :func:`os.path.isreserved` to detect reserved paths on Windows.

Expand Down
8 changes: 7 additions & 1 deletion Doc/library/argparse.rst
Original file line number Diff line number Diff line change
Expand Up @@ -434,12 +434,18 @@ arguments they contain. For example::
>>> parser.parse_args(['-f', 'foo', '@args.txt'])
Namespace(f='bar')

Arguments read from a file must by default be one per line (but see also
Arguments read from a file must be one per line by default (but see also
:meth:`~ArgumentParser.convert_arg_line_to_args`) and are treated as if they
were in the same place as the original file referencing argument on the command
line. So in the example above, the expression ``['-f', 'foo', '@args.txt']``
is considered equivalent to the expression ``['-f', 'foo', '-f', 'bar']``.

.. note::

Empty lines are treated as empty strings (``''``), which are allowed as values but
not as arguments. Empty lines that are read as arguments will result in an
"unrecognized arguments" error.

:class:`ArgumentParser` uses :term:`filesystem encoding and error handler`
to read the file containing arguments.

Expand Down
20 changes: 18 additions & 2 deletions Doc/library/ctypes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,24 @@ Fundamental data types
+----------------------+------------------------------------------+----------------------------+
| :class:`c_int` | :c:expr:`int` | int |
+----------------------+------------------------------------------+----------------------------+
| :class:`c_int8` | :c:type:`int8_t` | int |
+----------------------+------------------------------------------+----------------------------+
| :class:`c_int16` | :c:type:`int16_t` | int |
+----------------------+------------------------------------------+----------------------------+
| :class:`c_int32` | :c:type:`int32_t` | int |
+----------------------+------------------------------------------+----------------------------+
| :class:`c_int64` | :c:type:`int64_t` | int |
+----------------------+------------------------------------------+----------------------------+
| :class:`c_uint` | :c:expr:`unsigned int` | int |
+----------------------+------------------------------------------+----------------------------+
| :class:`c_uint8` | :c:type:`uint8_t` | int |
+----------------------+------------------------------------------+----------------------------+
| :class:`c_uint16` | :c:type:`uint16_t` | int |
+----------------------+------------------------------------------+----------------------------+
| :class:`c_uint32` | :c:type:`uint32_t` | int |
+----------------------+------------------------------------------+----------------------------+
| :class:`c_uint64` | :c:type:`uint64_t` | int |
+----------------------+------------------------------------------+----------------------------+
| :class:`c_long` | :c:expr:`long` | int |
+----------------------+------------------------------------------+----------------------------+
| :class:`c_ulong` | :c:expr:`unsigned long` | int |
Expand Down Expand Up @@ -2524,7 +2540,7 @@ These are the fundamental ctypes data types:

.. class:: c_int8

Represents the C 8-bit :c:expr:`signed int` datatype. Usually an alias for
Represents the C 8-bit :c:expr:`signed int` datatype. It is an alias for
:class:`c_byte`.


Expand Down Expand Up @@ -2599,7 +2615,7 @@ These are the fundamental ctypes data types:

.. class:: c_uint8

Represents the C 8-bit :c:expr:`unsigned int` datatype. Usually an alias for
Represents the C 8-bit :c:expr:`unsigned int` datatype. It is an alias for
:class:`c_ubyte`.


Expand Down
2 changes: 1 addition & 1 deletion Doc/library/fnmatch.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ a :class:`!str` filename, and vice-versa.

Finally, note that :func:`functools.lru_cache` with a *maxsize* of 32768
is used to cache the (typed) compiled regex patterns in the following
functions: :func:`fnmatch`, :func:`fnmatchcase`, :func:`.filter`.
functions: :func:`fnmatch`, :func:`fnmatchcase`, :func:`.filter`, :func:`.filterfalse`.


.. function:: fnmatch(name, pat)
Expand Down
4 changes: 2 additions & 2 deletions Doc/library/fractions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ another rational number, or from a string.

The first version requires that *numerator* and *denominator* are instances
of :class:`numbers.Rational` and returns a new :class:`Fraction` instance
with value ``numerator/denominator``. If *denominator* is ``0``, it
raises a :exc:`ZeroDivisionError`.
with value equal to ``numerator/denominator`` where the denominator is positive.
If *denominator* is ``0``, it raises a :exc:`ZeroDivisionError`.

The second version requires that *number* is an instance of
:class:`numbers.Rational` or has the :meth:`!as_integer_ratio` method
Expand Down
12 changes: 11 additions & 1 deletion Doc/library/ipaddress.rst
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,16 @@ write code that handles both IP versions correctly. Address objects are

.. attribute:: is_reserved

``True`` if the address is otherwise IETF reserved.
``True`` if the address is noted as reserved by the IETF.
For IPv4, this is only ``240.0.0.0/4``, the ``Reserved`` address block.
For IPv6, this is all addresses `allocated <iana-ipv6-address-space_>`__ as
``Reserved by IETF`` for future use.

.. note:: For IPv4, ``is_reserved`` is not related to the address block value of the
``Reserved-by-Protocol`` column in iana-ipv4-special-registry_.

.. caution:: For IPv6, ``fec0::/10`` a former Site-Local scoped address prefix is
currently excluded from that list (see :attr:`~IPv6Address.is_site_local` & :rfc:`3879`).

.. attribute:: is_loopback

Expand All @@ -261,6 +270,7 @@ write code that handles both IP versions correctly. Address objects are

.. _iana-ipv4-special-registry: https://www.iana.org/assignments/iana-ipv4-special-registry/iana-ipv4-special-registry.xhtml
.. _iana-ipv6-special-registry: https://www.iana.org/assignments/iana-ipv6-special-registry/iana-ipv6-special-registry.xhtml
.. _iana-ipv6-address-space: https://www.iana.org/assignments/ipv6-address-space/ipv6-address-space.xhtml

.. method:: IPv4Address.__format__(fmt)

Expand Down
9 changes: 7 additions & 2 deletions Doc/library/multiprocessing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -936,8 +936,13 @@ For an example of the usage of queues for interprocess communication see

.. method:: close()

Indicate that no more data will be put on this queue by the current
process. The background thread will quit once it has flushed all buffered
Close the queue: release internal resources.

A queue must not be used anymore after it is closed. For example,
:meth:`~Queue.get`, :meth:`~Queue.put` and :meth:`~Queue.empty`
methods must no longer be called.

The background thread will quit once it has flushed all buffered
data to the pipe. This is called automatically when the queue is garbage
collected.

Expand Down
14 changes: 0 additions & 14 deletions Doc/library/pathlib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -542,20 +542,6 @@ Pure paths provide the following methods and properties:
Passing additional arguments is deprecated; if supplied, they are joined
with *other*.

.. method:: PurePath.is_reserved()

With :class:`PureWindowsPath`, return ``True`` if the path is considered
reserved under Windows, ``False`` otherwise. With :class:`PurePosixPath`,
``False`` is always returned.

.. versionchanged:: 3.13
Windows path names that contain a colon, or end with a dot or a space,
are considered reserved. UNC paths may be reserved.

.. deprecated-removed:: 3.13 3.15
This method is deprecated; use :func:`os.path.isreserved` to detect
reserved paths on Windows.

.. method:: PurePath.joinpath(*pathsegments)

Calling this method is equivalent to combining the path with each of
Expand Down
11 changes: 7 additions & 4 deletions Doc/library/urllib.request.rst
Original file line number Diff line number Diff line change
Expand Up @@ -829,10 +829,13 @@ The following attribute and methods should only be used by classes derived from
errors. It will be called automatically by the :class:`OpenerDirector` getting
the error, and should not normally be called in other circumstances.

*req* will be a :class:`Request` object, *fp* will be a file-like object with
the HTTP error body, *code* will be the three-digit code of the error, *msg*
will be the user-visible explanation of the code and *hdrs* will be a mapping
object with the headers of the error.
:class:`OpenerDirector` will call this method with five positional arguments:

1. a :class:`Request` object,
#. a file-like object with the HTTP error body,
#. the three-digit code of the error, as a string,
#. the user-visible explanation of the code, as as string, and
#. the headers of the error, as a mapping object.

Return values and exceptions raised should be the same as those of
:func:`urlopen`.
Expand Down
3 changes: 3 additions & 0 deletions Doc/using/configure.rst
Original file line number Diff line number Diff line change
Expand Up @@ -802,6 +802,9 @@ Debug options
.. option:: --with-address-sanitizer

Enable AddressSanitizer memory error detector, ``asan`` (default is no).
To improve ASan detection capabilities you may also want to combine this
with :option:`--without-pymalloc` to disable the specialized small-object
allocator whose allocations are not tracked by ASan.

.. 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 @@ -1917,7 +1917,7 @@ New Deprecations

* :mod:`pathlib`:

* Deprecate :meth:`.PurePath.is_reserved`,
* Deprecate :meth:`!.PurePath.is_reserved`,
to be removed in Python 3.15.
Use :func:`os.path.isreserved` to detect reserved paths on Windows.
(Contributed by Barney Gale in :gh:`88569`.)
Expand Down
11 changes: 10 additions & 1 deletion Doc/whatsnew/3.15.rst
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ running Python processes without requiring code modification or process restart.
Unlike deterministic profilers (:mod:`cProfile` and :mod:`profile`) that instrument
every function call, the sampling profiler periodically captures stack traces from
running processes. This approach provides virtually zero overhead while achieving
sampling rates of **up to 200,000 Hz**, making it the fastest sampling profiler
sampling rates of **up to 1,000,000 Hz**, making it the fastest sampling profiler
available for Python (at the time of its contribution) and ideal for debugging
performance issues in production environments.

Expand Down Expand Up @@ -373,6 +373,14 @@ http.server
(Contributed by Bénédikt Tran in :gh:`133810`.)


pathlib
-------

* Removed deprecated :meth:`!pathlib.PurePath.is_reserved`.
Use :func:`os.path.isreserved` to detect reserved paths on Windows.
(Contributed by Nikita Sobolev in :gh:`133875`.)


platform
--------

Expand Down Expand Up @@ -482,6 +490,7 @@ Porting to Python 3.15
The |pythoncapi_compat_project| can be used to get most of these new
functions on Python 3.14 and older.


Deprecated C APIs
-----------------

Expand Down
4 changes: 2 additions & 2 deletions Lib/_pyrepl/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,14 +241,14 @@ def is_soft_keyword_used(*tokens: TI | None) -> bool:
return s in keyword_first_sets_match
return True
case (
None | TI(T.NEWLINE) | TI(T.INDENT) | TI(string=":"),
None | TI(T.NEWLINE) | TI(T.INDENT) | TI(T.DEDENT) | TI(string=":"),
TI(string="case"),
TI(T.NUMBER | T.STRING | T.FSTRING_START | T.TSTRING_START)
| TI(T.OP, string="(" | "*" | "-" | "[" | "{")
):
return True
case (
None | TI(T.NEWLINE) | TI(T.INDENT) | TI(string=":"),
None | TI(T.NEWLINE) | TI(T.INDENT) | TI(T.DEDENT) | TI(string=":"),
TI(string="case"),
TI(T.NAME, string=s)
):
Expand Down
2 changes: 1 addition & 1 deletion Lib/dataclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -1265,7 +1265,7 @@ def _create_slots(defined_fields, inherited_slots, field_names, weakref_slot):
doc = getattr(defined_fields.get(slot), 'doc', None)
if doc is not None:
seen_docs = True
slots.update({slot: doc})
slots[slot] = doc

# We only return dict if there's at least one doc member,
# otherwise we return tuple, which is the old default format.
Expand Down
2 changes: 1 addition & 1 deletion Lib/enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -1991,7 +1991,7 @@ def __call__(self, enumeration):
if 2**i not in values:
missing.append(2**i)
elif enum_type == 'enum':
# check for powers of one
# check for missing consecutive integers
for i in range(low+1, high):
if i not in values:
missing.append(i)
Expand Down
8 changes: 2 additions & 6 deletions Lib/multiprocessing/resource_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,8 @@ def cleanup_noop(name):
# absence of POSIX named semaphores. In that case, no named semaphores were
# ever opened, so no cleanup would be necessary.
if hasattr(_multiprocessing, 'sem_unlink'):
_CLEANUP_FUNCS.update({
'semaphore': _multiprocessing.sem_unlink,
})
_CLEANUP_FUNCS.update({
'shared_memory': _posixshmem.shm_unlink,
})
_CLEANUP_FUNCS['semaphore'] = _multiprocessing.sem_unlink
_CLEANUP_FUNCS['shared_memory'] = _posixshmem.shm_unlink


class ReentrantCallError(RuntimeError):
Expand Down
12 changes: 0 additions & 12 deletions Lib/pathlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,18 +519,6 @@ def is_absolute(self):
return False
return self.parser.isabs(self)

def is_reserved(self):
"""Return True if the path contains one of the special names reserved
by the system, if any."""
import warnings
msg = ("pathlib.PurePath.is_reserved() is deprecated and scheduled "
"for removal in Python 3.15. Use os.path.isreserved() to "
"detect reserved paths on Windows.")
warnings._deprecated("pathlib.PurePath.is_reserved", msg, remove=(3, 15))
if self.parser is ntpath:
return self.parser.isreserved(self)
return False

def as_uri(self):
"""Return the path as a URI."""
import warnings
Expand Down
25 changes: 25 additions & 0 deletions Lib/test/test_capi/test_emscripten.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import unittest
from test.support import is_emscripten

if not is_emscripten:
raise unittest.SkipTest("Emscripten-only test")

from _testinternalcapi import emscripten_set_up_async_input_device
from pathlib import Path


class EmscriptenAsyncInputDeviceTest(unittest.TestCase):
def test_emscripten_async_input_device(self):
jspi_supported = emscripten_set_up_async_input_device()
p = Path("/dev/blah")
self.addCleanup(p.unlink)
if not jspi_supported:
with open(p, "r") as f:
self.assertRaises(OSError, f.readline)
return

with open(p, "r") as f:
for _ in range(10):
self.assertEqual(f.readline().strip(), "ab")
self.assertEqual(f.readline().strip(), "fi")
self.assertEqual(f.readline().strip(), "xy")
6 changes: 0 additions & 6 deletions Lib/test/test_pathlib/test_pathlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,12 +539,6 @@ def test_with_stem_empty(self):
self.assertRaises(ValueError, P('a/b').with_stem, '')
self.assertRaises(ValueError, P('a/b').with_stem, '.')

def test_is_reserved_deprecated(self):
P = self.cls
p = P('a/b')
with self.assertWarns(DeprecationWarning):
p.is_reserved()

def test_full_match_case_sensitive(self):
P = self.cls
self.assertFalse(P('A.py').full_match('a.PY', case_sensitive=True))
Expand Down
12 changes: 7 additions & 5 deletions Lib/test/test_pyrepl/test_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,8 @@ def funct(case: str = sys.platform) -> None:
)
match case:
case "emscripten": print("on the web")
case "ios" | "android": print("on the phone")
case "ios" | "android":
print("on the phone")
case _: print('arms around', match.group(1))
"""
)
Expand All @@ -393,7 +394,8 @@ def funct(case: str = sys.platform) -> None:
{o}){z}
{K}match{z} case{o}:{z}
{K}case{z} {s}"emscripten"{z}{o}:{z} {b}print{z}{o}({z}{s}"on the web"{z}{o}){z}
{K}case{z} {s}"ios"{z} {o}|{z} {s}"android"{z}{o}:{z} {b}print{z}{o}({z}{s}"on the phone"{z}{o}){z}
{K}case{z} {s}"ios"{z} {o}|{z} {s}"android"{z}{o}:{z}
{b}print{z}{o}({z}{s}"on the phone"{z}{o}){z}
{K}case{z} {K}_{z}{o}:{z} {b}print{z}{o}({z}{s}'arms around'{z}{o},{z} match{o}.{z}group{o}({z}{n}1{z}{o}){z}{o}){z}
"""
)
Expand All @@ -402,14 +404,14 @@ def funct(case: str = sys.platform) -> None:
reader, _ = handle_all_events(events)
self.assert_screen_equal(reader, code, clean=True)
self.assert_screen_equal(reader, expected_sync)
self.assertEqual(reader.pos, 2**7 + 2**8)
self.assertEqual(reader.cxy, (0, 14))
self.assertEqual(reader.pos, 396)
self.assertEqual(reader.cxy, (0, 15))

async_msg = "{k}async{z} ".format(**colors)
expected_async = expected.format(a=async_msg, **colors)
more_events = itertools.chain(
code_to_events(code),
[Event(evt="key", data="up", raw=bytearray(b"\x1bOA"))] * 13,
[Event(evt="key", data="up", raw=bytearray(b"\x1bOA"))] * 14,
code_to_events("async "),
)
reader, _ = handle_all_events(more_events)
Expand Down
2 changes: 1 addition & 1 deletion Lib/tkinter/scrolledtext.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def __init__(self, master=None, **kw):
self.vbar = Scrollbar(self.frame)
self.vbar.pack(side=RIGHT, fill=Y)

kw.update({'yscrollcommand': self.vbar.set})
kw['yscrollcommand'] = self.vbar.set
Text.__init__(self, self.frame, **kw)
self.pack(side=LEFT, fill=BOTH, expand=True)
self.vbar['command'] = self.yview
Expand Down
2 changes: 1 addition & 1 deletion Lib/xmlrpc/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ def register_multicall_functions(self):

see http://www.xmlrpc.com/discuss/msgReader$1208"""

self.funcs.update({'system.multicall' : self.system_multicall})
self.funcs['system.multicall'] = self.system_multicall

def _marshaled_dispatch(self, data, dispatch_method = None, path = None):
"""Dispatches an XML-RPC method from marshalled (XML) data.
Expand Down
Loading
Loading