Skip to content

Commit a5983e6

Browse files
Merge branch 'main' into fcntl-buffer-overflow
2 parents 55de962 + 6677c2c commit a5983e6

Some content is hidden

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

66 files changed

+788
-458
lines changed

Doc/howto/remote_debugging.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ file format structures from the binary file on disk. The ELF header contains a
110110
pointer to the section header table. Each section header contains metadata about
111111
a section including its name (stored in a separate string table), offset, and
112112
size. To find a specific section like .PyRuntime, you need to walk through these
113-
headers and match the section name. The section header then provdes the offset
113+
headers and match the section name. The section header then provides the offset
114114
where that section exists in the file, which can be used to calculate its
115115
runtime address when the binary is loaded into memory.
116116

Doc/library/faulthandler.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ Dumping the C stack
8484
C Stack Compatibility
8585
*********************
8686

87-
If the system does not support the C-level :manpage:`backtrace(3)`,
88-
:manpage:`backtrace_symbols(3)`, or :manpage:`dladdr(3)`, then C stack dumps
89-
will not work. An error will be printed instead of the stack.
87+
If the system does not support the C-level :manpage:`backtrace(3)`
88+
or :manpage:`dladdr1(3)`, then C stack dumps will not work.
89+
An error will be printed instead of the stack.
9090

9191
Additionally, some compilers do not support :term:`CPython's <CPython>`
9292
implementation of C stack dumps. As a result, a different error may be printed

Doc/library/importlib.metadata.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ Distribution files
297297
package is not installed in the current Python environment.
298298

299299
Returns :const:`None` if the distribution is found but the installation
300-
database records reporting the files associated with the distribuion package
300+
database records reporting the files associated with the distribution package
301301
are missing.
302302

303303
.. class:: PackagePath

Doc/library/socket.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -476,8 +476,8 @@ Constants
476476
network interface instead of its name.
477477

478478
.. versionchanged:: 3.14
479-
Added missing ``IP_RECVERR``, ``IPV6_RECVERR``, ``IP_RECVTTL``, and
480-
``IP_RECVORIGDSTADDR`` on Linux.
479+
Added missing ``IP_FREEBIND``, ``IP_RECVERR``, ``IPV6_RECVERR``,
480+
``IP_RECVTTL``, and ``IP_RECVORIGDSTADDR`` on Linux.
481481

482482
.. versionchanged:: 3.14
483483
Added support for ``TCP_QUICKACK`` on Windows platforms when available.

Doc/library/tarfile.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ Some facts and figures:
112112
``'w|bz2'``, :func:`tarfile.open` accepts the keyword argument
113113
*compresslevel* (default ``9``) to specify the compression level of the file.
114114

115-
For modes ``'w:xz'`` and ``'x:xz'``, :func:`tarfile.open` accepts the
115+
For modes ``'w:xz'``, ``'x:xz'`` and ``'w|xz'``, :func:`tarfile.open` accepts the
116116
keyword argument *preset* to specify the compression level of the file.
117117

118118
For special purposes, there is a second format for *mode*:
@@ -167,6 +167,9 @@ Some facts and figures:
167167
.. versionchanged:: 3.12
168168
The *compresslevel* keyword argument also works for streams.
169169

170+
.. versionchanged:: next
171+
The *preset* keyword argument also works for streams.
172+
170173

171174
.. class:: TarFile
172175
:noindex:

Doc/whatsnew/3.14.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1580,6 +1580,11 @@ Deprecated
15801580
or *sequence* as keyword arguments is now deprecated.
15811581
(Contributed by Kirill Podoprigora in :gh:`121676`.)
15821582

1583+
* :mod:`logging`:
1584+
Support for custom logging handlers with the *strm* argument is deprecated
1585+
and scheduled for removal in Python 3.16. Define handlers with the *stream*
1586+
argument instead. (Contributed by Mariusz Felisiak in :gh:`115032`.)
1587+
15831588
* :mod:`!nturl2path`: This module is now deprecated. Call
15841589
:func:`urllib.request.url2pathname` and :func:`~urllib.request.pathname2url`
15851590
instead.

Lib/_pyrepl/readline.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
# "set_pre_input_hook",
9191
"set_startup_hook",
9292
"write_history_file",
93+
"append_history_file",
9394
# ---- multiline extensions ----
9495
"multiline_input",
9596
]
@@ -453,6 +454,7 @@ def read_history_file(self, filename: str = gethistoryfile()) -> None:
453454
del buffer[:]
454455
if line:
455456
history.append(line)
457+
self.set_history_length(self.get_current_history_length())
456458

457459
def write_history_file(self, filename: str = gethistoryfile()) -> None:
458460
maxlength = self.saved_history_length
@@ -464,6 +466,19 @@ def write_history_file(self, filename: str = gethistoryfile()) -> None:
464466
entry = entry.replace("\n", "\r\n") # multiline history support
465467
f.write(entry + "\n")
466468

469+
def append_history_file(self, filename: str = gethistoryfile()) -> None:
470+
reader = self.get_reader()
471+
saved_length = self.get_history_length()
472+
length = self.get_current_history_length() - saved_length
473+
history = reader.get_trimmed_history(length)
474+
f = open(os.path.expanduser(filename), "a",
475+
encoding="utf-8", newline="\n")
476+
with f:
477+
for entry in history:
478+
entry = entry.replace("\n", "\r\n") # multiline history support
479+
f.write(entry + "\n")
480+
self.set_history_length(saved_length + length)
481+
467482
def clear_history(self) -> None:
468483
del self.get_reader().history[:]
469484

@@ -533,6 +548,7 @@ def insert_text(self, text: str) -> None:
533548
get_current_history_length = _wrapper.get_current_history_length
534549
read_history_file = _wrapper.read_history_file
535550
write_history_file = _wrapper.write_history_file
551+
append_history_file = _wrapper.append_history_file
536552
clear_history = _wrapper.clear_history
537553
get_history_item = _wrapper.get_history_item
538554
remove_history_item = _wrapper.remove_history_item

Lib/_pyrepl/simple_interact.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@
3030
import os
3131
import sys
3232
import code
33+
import warnings
3334

34-
from .readline import _get_reader, multiline_input
35+
from .readline import _get_reader, multiline_input, append_history_file
3536

3637

3738
_error: tuple[type[Exception], ...] | type[Exception]
@@ -144,6 +145,10 @@ def maybe_run_command(statement: str) -> bool:
144145
input_name = f"<python-input-{input_n}>"
145146
more = console.push(_strip_final_indent(statement), filename=input_name, _symbol="single") # type: ignore[call-arg]
146147
assert not more
148+
try:
149+
append_history_file()
150+
except (FileNotFoundError, PermissionError, OSError) as e:
151+
warnings.warn(f"failed to open the history file for writing: {e}")
147152
input_n += 1
148153
except KeyboardInterrupt:
149154
r = _get_reader()

Lib/ast.py

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,24 @@
11
"""
2-
ast
3-
~~~
4-
5-
The `ast` module helps Python applications to process trees of the Python
6-
abstract syntax grammar. The abstract syntax itself might change with
7-
each Python release; this module helps to find out programmatically what
8-
the current grammar looks like and allows modifications of it.
9-
10-
An abstract syntax tree can be generated by passing `ast.PyCF_ONLY_AST` as
11-
a flag to the `compile()` builtin function or by using the `parse()`
12-
function from this module. The result will be a tree of objects whose
13-
classes all inherit from `ast.AST`.
14-
15-
A modified abstract syntax tree can be compiled into a Python code object
16-
using the built-in `compile()` function.
17-
18-
Additionally various helper functions are provided that make working with
19-
the trees simpler. The main intention of the helper functions and this
20-
module in general is to provide an easy to use interface for libraries
21-
that work tightly with the python syntax (template engines for example).
22-
23-
24-
:copyright: Copyright 2008 by Armin Ronacher.
25-
:license: Python License.
2+
The `ast` module helps Python applications to process trees of the Python
3+
abstract syntax grammar. The abstract syntax itself might change with
4+
each Python release; this module helps to find out programmatically what
5+
the current grammar looks like and allows modifications of it.
6+
7+
An abstract syntax tree can be generated by passing `ast.PyCF_ONLY_AST` as
8+
a flag to the `compile()` builtin function or by using the `parse()`
9+
function from this module. The result will be a tree of objects whose
10+
classes all inherit from `ast.AST`.
11+
12+
A modified abstract syntax tree can be compiled into a Python code object
13+
using the built-in `compile()` function.
14+
15+
Additionally various helper functions are provided that make working with
16+
the trees simpler. The main intention of the helper functions and this
17+
module in general is to provide an easy to use interface for libraries
18+
that work tightly with the python syntax (template engines for example).
19+
20+
:copyright: Copyright 2008 by Armin Ronacher.
21+
:license: Python License.
2622
"""
2723
from _ast import *
2824

Lib/bz2.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
__author__ = "Nadeem Vawda <[email protected]>"
1111

1212
from builtins import open as _builtin_open
13+
from compression._common import _streams
1314
import io
1415
import os
15-
import _compression
1616

1717
from _bz2 import BZ2Compressor, BZ2Decompressor
1818

@@ -23,7 +23,7 @@
2323
_MODE_WRITE = 3
2424

2525

26-
class BZ2File(_compression.BaseStream):
26+
class BZ2File(_streams.BaseStream):
2727

2828
"""A file object providing transparent bzip2 (de)compression.
2929
@@ -88,7 +88,7 @@ def __init__(self, filename, mode="r", *, compresslevel=9):
8888
raise TypeError("filename must be a str, bytes, file or PathLike object")
8989

9090
if self._mode == _MODE_READ:
91-
raw = _compression.DecompressReader(self._fp,
91+
raw = _streams.DecompressReader(self._fp,
9292
BZ2Decompressor, trailing_error=OSError)
9393
self._buffer = io.BufferedReader(raw)
9494
else:
@@ -248,7 +248,7 @@ def writelines(self, seq):
248248
249249
Line separators are not added between the written byte strings.
250250
"""
251-
return _compression.BaseStream.writelines(self, seq)
251+
return _streams.BaseStream.writelines(self, seq)
252252

253253
def seek(self, offset, whence=io.SEEK_SET):
254254
"""Change the file position.

0 commit comments

Comments
 (0)