8000 Merge remote-tracking branch 'origin/main' into generate-all-uops · python/cpython@9d65bb9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9d65bb9

Browse files
committed
Merge remote-tracking branch 'origin/main' into generate-all-uops
2 parents d403040 + 2f3ee02 commit 9d65bb9

30 files changed

+350
-101
lines changed

.coveragerc

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[run]
2+
branch = True
3+
4+
[report]
5+
# Regexes for lines to exclude from consideration
6+
exclude_lines =
7+
# Don't complain if non-runnable code isn't run:
8+
if 0:
9+
if __name__ == .__main__.:
10+
11+
.*# pragma: no cover
12+
.*# pragma: no branch
13+
14+
# Additions for IDLE:
15+
.*# htest #
16+
if not (_htest or _utest):
17+
if not .*_utest:
18+
if .*_htest:
19+

Doc/library/typing.rst

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2849,6 +2849,9 @@ Functions and decorators
28492849
This wraps the decorator with something that wraps the decorated
28502850
function in :func:`no_type_check`.
28512851

2852+
.. deprecated-removed:: 3.13 3.15
2853+
No type checker ever added support for ``@no_type_check_decorator``. It
2854+
is therefore deprecated, and will be removed in Python 3.15.
28522855

28532856
.. decorator:: override
28542857

@@ -3648,18 +3651,20 @@ Certain features in ``typing`` are deprecated and may be removed in a future
36483651
version of Python. The following table summarizes major deprecations for your
36493652
convenience. This is subject to change, and not all deprecations are listed.
36503653

3651-
+----------------------------------+---------------+-------------------+----------------+
3652-
| Feature | Deprecated in | Projected removal | PEP/issue |
3653-
+==================================+===============+===================+================+
3654-
| ``typing`` versions of standard | 3.9 | Undecided | :pep:`585` |
3655-
| collections | | | |
3656-
+----------------------------------+---------------+-------------------+----------------+
3657-
| ``typing.ByteString`` | 3.9 | 3.14 | :gh:`91896` |
3658-
+----------------------------------+---------------+-------------------+----------------+
3659-
| ``typing.Text`` | 3.11 | Undecided | :gh:`92332` |
3660-
+----------------------------------+---------------+-------------------+----------------+
3661-
| ``typing.Hashable`` and | 3.12 | Undecided | :gh:`94309` |
3662-
| ``typing.Sized`` | | | |
3663-
+----------------------------------+---------------+-------------------+----------------+
3664-
| ``typing.TypeAlias`` | 3.12 | Undecided | :pep:`695` |
3665-
+----------------------------------+---------------+-------------------+----------------+
3654+
+-------------------------------------+---------------+-------------------+----------------+
3655+
| Feature | Deprecated in | Projected removal | PEP/issue |
3656+
+=====================================+===============+===================+================+
3657+
| ``typing`` versions of standard | 3.9 | Undecided | :pep:`585` |
3658+
| collections | | | |
3659+
+-------------------------------------+---------------+-------------------+----------------+
3660+
| ``typing.ByteString`` | 3.9 | 3.14 | :gh:`91896` |
3661+
+-------------------------------------+---------------+-------------------+----------------+
3662+
| ``typing.Text`` | 3.11 | Undecided | :gh:`92332` |
3663+
+-------------------------------------+---------------+-------------------+----------------+
3664+
| ``typing.Hashable`` and | 3.12 | Undecided | :gh:`94309` |
3665+
| ``typing.Sized`` | | | |
3666+
+-------------------------------------+---------------+-------------------+----------------+
3667+
| ``typing.TypeAlias`` | 3.12 | Undecided | :pep:`695` |
3668+
+-------------------------------------+---------------+-------------------+----------------+
3669+
| ``typing.no_type_check_decorator`` | 3.13 | 3.15 | :gh:`106309` |
3670+
+-------------------------------------+---------------+-------------------+----------------+

Doc/whatsnew/3.13.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,10 @@ Deprecated
161161
``NT = NamedTuple("NT", [])``. To create a TypedDict class with 0 fields, use
162162
``class TD(TypedDict): pass`` or ``TD = TypedDict("TD", {})``.
163163
(Contributed by Alex Waygood in :gh:`105566` and :gh:`105570`.)
164+
* :func:`typing.no_type_check_decorator` is deprecated, and scheduled for
165+
removal in Python 3.15. After eight years in the :mod:`typing` module, it
166+
has yet to be supported by any major type checkers.
167+
(Contributed by Alex Waygood in :gh:`106309`.)
164168

165169
* :mod:`array`'s ``'u'`` format code, deprecated in docs since Python 3.3,
166170
emits :exc:`DeprecationWarning` since 3.13

Include/internal/pycore_opcode_metadata.h

Lines changed: 12 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Lib/asyncio/base_events.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,7 @@ def call_later(self, delay, callback, *args, context=None):
727727
always relative to the current time.
728728
729729
Each callback will be called exactly once. If two callbacks
730-
are scheduled for exactly the same time, it undefined which
730+
are scheduled for exactly the same time, it is undefined which
731731
will be called first.
732732
733733
Any positional arguments after the callback will be passed to

Lib/asyncio/events.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ class AbstractEventLoopPolicy:
617617
def get_event_loop(self):
618618
"""Get the event loop for the current context.
619619
620-
Returns an event loop object implementing the BaseEventLoop interface,
620+
Returns an event loop object implementing the AbstractEventLoop interface,
621621
or raises an exception in case no event loop has been set for the
622622
current context and the current policy does not specify to create one.
623623

Lib/email/feedparser.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
headerRE = re.compile(r'^(From |[\041-\071\073-\176]*:|[\t ])')
3838
EMPTYSTRING = ''
3939
NL = '\n'
40+
boundaryendRE = re.compile(
41+
r'(?P<end>--)?(?P<ws>[ \t]*)(?P<linesep>\r\n|\r|\n)?$')
4042

4143
NeedMoreData = object()
4244

@@ -327,9 +329,10 @@ def _parsegen(self):
327329
# this onto the input stream until we've scanned past the
328330
# preamble.
329331
separator = '--' + boundary
330-
boundaryre = re.compile(
331-
'(?P<sep>' + re.escape(separator) +
332-
r')(?P<end>--)?(?P<ws>[ \t]*)(?P<linesep>\r\n|\r|\n)?$')
332+
def boundarymatch(line):
333+
if not line.startswith(separator):
334+
return None
335+
return boundaryendRE.match(line, len(separator))
333336
capturing_preamble = True
334337
preamble = []
335338
linesep = False
@@ -341,7 +344,7 @@ def _parsegen(self):
341344
continue
342345
if line == '':
343346
break
344-
mo = boundaryre.match(line)
347+
mo = boundarymatch(line)
345348
if mo:
346349
# If we're looking at the end boundary, we're done with
347350
# this multipart. If there was a newline at the end of
@@ -373,13 +376,13 @@ def _parsegen(self):
373376
if line is NeedMoreData:
374377
yield NeedMoreData
375378
continue
376-
mo = boundaryre.match(line)
379+
mo = boundarymatch(line)
377380
if not mo:
378381
self._input.unreadline(line)
379382
break
380383
# Recurse to parse this subpart; the input stream points
381384
# at the subpart's first line.
382-
self._input.push_eof_matcher(boundaryre.match)
385+
self._input.push_eof_matcher(boundarymatch)
383386
for retval in self._parsegen():
384387
if retval is NeedMoreData:
385388
yield NeedMoreData

Lib/test/test_mmap.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,27 @@ def test_find_end(self):
299299
self.assertEqual(m.find(b'one', 1, -2), -1)
300300
self.assertEqual(m.find(bytearray(b'one')), 0)
301301

302+
for i in range(-n-1, n+1):
303+
for j in range(-n-1, n+1):
304+
for p in [b"o", b"on", b"two", b"ones", b"s"]:
305+
expected = data.find(p, i, j)
306+
self.assertEqual(m.find(p, i, j), expected, (p, i, j))
307+
308+
def test_find_does_not_access_beyond_buffer(self):
309+
try:
310+
flags = mmap.MAP_PRIVATE | mmap.MAP_ANONYMOUS
311+
PAGESIZE = mmap.PAGESIZE
312+
PROT_NONE = 0
313+
PROT_READ = mmap.PROT_READ
314+
except AttributeError as e:
315+
raise unittest.SkipTest("mmap flags unavailable") from e
316+
for i in range(0, 2049):
317+
with mmap.mmap(-1, PAGESIZE * (i + 1),
318+
flags=flags, prot=PROT_NONE) as guard:
319+
with mmap.mmap(-1, PAGESIZE * (i + 2048),
320+
flags=flags, prot=PROT_READ) as fm:
321+
fm.find(b"fo", -2)
322+
302323

303324
def test_rfind(self):
304325
# test the new 'end' parameter works as expected

Lib/test/test_typing.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5794,10 +5794,14 @@ class F:
57945794
get_type_hints(clazz)
57955795

57965796
def test_meta_no_type_check(self):
5797-
5798-
@no_type_check_decorator
5799-
def magic_decorator(func):
5800-
return func
5797+
depr_msg = (
5798+
"'typing.no_type_check_decorator' is deprecated "
5799+
"and slated for removal in Python 3.15"
5800+
)
5801+
with self.assertWarnsRegex(DeprecationWarning, depr_msg):
5802+
@no_type_check_decorator
5803+
def magic_decorator(func):
5804+
return func
58015805

58025806
self.assertEqual(magic_decorator.__name__, 'magic_decorator')
58035807

Lib/typing.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2395,6 +2395,8 @@ def no_type_check_decorator(decorator):
23952395
This wraps the decorator with something that wraps the decorated
23962396
function in @no_type_check.
23972397
"""
2398+
import warnings
2399+
warnings._deprecated("typing.no_type_check_decorator", remove=(3, 15))
23982400
@functools.wraps(decorator)
23992401
def wrapped_decorator(*args, **kwds):
24002402
func = decorator(*args, **kwds)

Lib/venv/scripts/common/Activate.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,8 @@ deactivate -nondestructive
219219
# that there is an activated venv.
220220
$env:VIRTUAL_ENV = $VenvDir
221221

222+
$env:VIRTUAL_ENV_PROMPT = $Prompt
223+
222224
if (-not $Env:VIRTUAL_ENV_DISABLE_PROMPT) {
223225

224< 10000 code>226
Write-Verbose "Setting prompt to '$Prompt'"
@@ -233,7 +235,6 @@ if (-not $Env:VIRTUAL_ENV_DISABLE_PROMPT) {
233235
Write-Host -NoNewline -ForegroundColor Green "($_PYTHON_VENV_PROMPT_PREFIX) "
234236
_OLD_VIRTUAL_PROMPT
235237
}
236-
$env:VIRTUAL_ENV_PROMPT = $Prompt
237238
}
238239

239240
# Clear PYTHONHOME

Lib/venv/scripts/common/activate

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ _OLD_VIRTUAL_PATH="$PATH"
5252
PATH="$VIRTUAL_ENV/__VENV_BIN_NAME__:$PATH"
5353
export PATH
5454

55+
VIRTUAL_ENV_PROMPT="__VENV_PROMPT__"
56+
export VIRTUAL_ENV_PROMPT
57+
5558
# unset PYTHONHOME if set
5659
# this will fail if PYTHONHOME is set to the empty string (which is bad anyway)
5760
# could use `if (set -u; : $PYTHONHOME) ;` in bash
@@ -64,8 +67,6 @@ if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT:-}" ] ; then
6467
_OLD_VIRTUAL_PS1="${PS1:-}"
6568
PS1="__VENV_PROMPT__${PS1:-}"
6669
export PS1
67-
VIRTUAL_ENV_PROMPT="__VENV_PROMPT__"
68-
export VIRTUAL_ENV_PROMPT
6970
fi
7071

7172
# This should detect bash and zsh, which have a hash command that must

Lib/venv/scripts/posix/activate.csh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ setenv VIRTUAL_ENV "__VENV_DIR__"
1313

1414
set _OLD_VIRTUAL_PATH="$PATH"
1515
setenv PATH "$VIRTUAL_ENV/__VENV_BIN_NAME__:$PATH"
16+
setenv VIRTUAL_ENV_PROMPT "__VENV_PROMPT__"
1617

1718

1819
set _OLD_VIRTUAL_PROMPT="$prompt"
1920

2021
if (! "$?VIRTUAL_ENV_DISABLE_PROMPT") then
2122
set prompt = "__VENV_PROMPT__$prompt"
22-
setenv VIRTUAL_ENV_PROMPT "__VENV_PROMPT__"
2323
endif
2424

2525
alias pydoc python -m pydoc

Lib/venv/scripts/posix/activate.fish

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ set -gx VIRTUAL_ENV "__VENV_DIR__"
3737

3838
set -gx _OLD_VIRTUAL_PATH $PATH
3939
set -gx PATH "$VIRTUAL_ENV/__VENV_BIN_NAME__" $PATH
40+
set -gx VIRTUAL_ENV_PROMPT "__VENV_PROMPT__"
4041

4142
# Unset PYTHONHOME if set.
4243
if set -q PYTHONHOME
@@ -65,5 +66,4 @@ if test -z "$VIRTUAL_ENV_DISABLE_PROMPT"
6566
end
6667

6768
set -gx _OLD_FISH_PROMPT_OVERRIDE "$VIRTUAL_ENV"
68-
set -gx VIRTUAL_ENV_PROMPT "__VENV_PROMPT__"
6969
end

Misc/ACKS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ Erik Bray
226226
Brian Brazil
227227
Demian Brecht
228228
Dave Brennan
229+
Christopher Richard James Brett
229230
Tom Bridgman
230231
Anthony Briggs
231232
Keith Briggs
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Prevent out-of-bounds memory access during ``mmap.find()`` calls.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Split :opcode:`LOAD_ATTR_INSTANCE_VALUE` into micro-ops.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Deprecate :func:`typing.no_type_check_decorator`. No major type checker ever
2+
added support for this decorator. Patch by Alex Waygood.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Set the environment variable ``VIRTUAL_ENV_PROMPT`` at :mod:`venv`
2+
activation, even when ``VIRTUAL_ENV_DISABLE_PROMPT`` is set.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Speed up parsing of emails by about 20% by not compiling a new regular
2+
expression for every single email.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add .coveragerc to cpython repository for use with coverage package.

0 commit comments

Comments
 (0)
0