Skip to content

Commit

Permalink
Merge commit '23db9c62272' into kenjin_tier2_inliner_redux
Browse files Browse the repository at this point in the history
  • Loading branch information
gvanrossum committed Mar 6, 2024
2 parents e84eeed + 23db9c6 commit dad9100
Show file tree
Hide file tree
Showing 32 changed files with 583 additions and 311 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ENV WASI_SDK_VERSION=20
ENV WASI_SDK_PATH=/opt/wasi-sdk

ENV WASMTIME_HOME=/opt/wasmtime
ENV WASMTIME_VERSION=14.0.4
ENV WASMTIME_VERSION=18.0.2
ENV WASMTIME_CPU_ARCH=x86_64

RUN dnf -y --nodocs --setopt=install_weak_deps=False install /usr/bin/{blurb,clang,curl,git,ln,tar,xz} 'dnf-command(builddep)' && \
Expand Down
2 changes: 1 addition & 1 deletion Include/internal/pycore_opcode_metadata.h

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

2 changes: 2 additions & 0 deletions Include/internal/pycore_optimizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,14 @@ extern _Py_UopsSymbol *_Py_uop_sym_new_type(
_Py_UOpsContext *ctx, PyTypeObject *typ);
extern _Py_UopsSymbol *_Py_uop_sym_new_const(_Py_UOpsContext *ctx, PyObject *const_val);
extern _Py_UopsSymbol *_Py_uop_sym_new_null(_Py_UOpsContext *ctx);
extern bool _Py_uop_sym_has_type(_Py_UopsSymbol *sym);
extern bool _Py_uop_sym_matches_type(_Py_UopsSymbol *sym, PyTypeObject *typ);
extern bool _Py_uop_sym_set_null(_Py_UopsSymbol *sym);
extern bool _Py_uop_sym_set_non_null(_Py_UopsSymbol *sym);
extern bool _Py_uop_sym_set_type(_Py_UopsSymbol *sym, PyTypeObject *typ);
extern bool _Py_uop_sym_set_const(_Py_UopsSymbol *sym, PyObject *const_val);
extern bool _Py_uop_sym_is_bottom(_Py_UopsSymbol *sym);
extern int _Py_uop_sym_truthiness(_Py_UopsSymbol *sym);


extern int _Py_uop_abstractcontext_init(_Py_UOpsContext *ctx);
Expand Down
40 changes: 20 additions & 20 deletions Include/internal/pycore_uop_ids.h

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

4 changes: 2 additions & 2 deletions Include/internal/pycore_uop_metadata.h

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

9 changes: 2 additions & 7 deletions Lib/test/libregrtest/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,15 +384,10 @@ def run_tests_sequentially(self, runtests) -> None:

result = self.run_test(test_name, runtests, tracer)

# Unload the newly imported test modules (best effort
# finalization). To work around gh-115490, don't unload
# test.support.interpreters and its submodules even if they
# weren't loaded before.
keep = "test.support.interpreters"
# Unload the newly imported test modules (best effort finalization)
new_modules = [module for module in sys.modules
if module not in save_modules and
module.startswith(("test.", "test_"))
and not module.startswith(keep)]
module.startswith(("test.", "test_"))]
for module in new_modules:
sys.modules.pop(module, None)
# Remove the attribute of the parent module.
Expand Down
5 changes: 5 additions & 0 deletions Lib/test/test__xxinterpchannels.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
channels = import_helper.import_module('_xxinterpchannels')


# Additional tests are found in Lib/test/test_interpreters/test_channels.py.
# New tests should be added there.
# XXX The tests here should be moved there. See the note under LowLevelTests.


##################################
# helpers

Expand Down
6 changes: 4 additions & 2 deletions Lib/test/test_capi/test_opt.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,8 @@ def testfunc(a):
ex = get_first_executor(testfunc)
self.assertIsNotNone(ex)
uops = get_opnames(ex)
self.assertIn("_GUARD_IS_NOT_NONE_POP", uops)
self.assertNotIn("_GUARD_IS_NONE_POP", uops)
self.assertNotIn("_GUARD_IS_NOT_NONE_POP", uops)

def test_pop_jump_if_not_none(self):
def testfunc(a):
Expand All @@ -347,7 +348,8 @@ def testfunc(a):
ex = get_first_executor(testfunc)
self.assertIsNotNone(ex)
uops = get_opnames(ex)
self.assertIn("_GUARD_IS_NONE_POP", uops)
self.assertNotIn("_GUARD_IS_NONE_POP", uops)
self.assertNotIn("_GUARD_IS_NOT_NONE_POP", uops)

def test_pop_jump_if_true(self):
def testfunc(n):
Expand Down
19 changes: 19 additions & 0 deletions Lib/test/test_interpreters/test_channels.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import importlib
import threading
from textwrap import dedent
import unittest
Expand All @@ -11,6 +12,24 @@
from .utils import _run_output, TestBase


class LowLevelTests(TestBase):

# The behaviors in the low-level module is important in as much
# as it is exercised by the high-level module. Therefore the
# most # important testing happens in the high-level tests.
# These low-level tests cover corner cases that are not
# encountered by the high-level module, thus they
# mostly shouldn't matter as much.

# Additional tests are found in Lib/test/test__xxinterpchannels.py.
# XXX Those should be either moved to LowLevelTests or eliminated
# in favor of high-level tests in this file.

def test_highlevel_reloaded(self):
# See gh-115490 (https://github.com/python/cpython/issues/115490).
importlib.reload(channels)


class TestChannels(TestBase):

def test_create(self):
Expand Down
15 changes: 15 additions & 0 deletions Lib/test/test_interpreters/test_queues.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import importlib
import threading
from textwrap import dedent
import unittest
Expand All @@ -20,6 +21,20 @@ def tearDown(self):
pass


class LowLevelTests(TestBase):

# The behaviors in the low-level module is important in as much
# as it is exercised by the high-level module. Therefore the
# most # important testing happens in the high-level tests.
# These low-level tests cover corner cases that are not
# encountered by the high-level module, thus they
# mostly shouldn't matter as much.

def test_highlevel_reloaded(self):
# See gh-115490 (https://github.com/python/cpython/issues/115490).
importlib.reload(queues)


class QueueTests(TestBase):

def test_create(self):
Expand Down
5 changes: 5 additions & 0 deletions Lib/test/test_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ def imul(a, b): a *= b
self.assertRaises((MemoryError, OverflowError), mul, lst, n)
self.assertRaises((MemoryError, OverflowError), imul, lst, n)

def test_empty_slice(self):
x = []
x[:] = x
self.assertEqual(x, [])

def test_list_resize_overflow(self):
# gh-97616: test new_allocated * sizeof(PyObject*) overflow
# check in list_resize()
Expand Down
6 changes: 6 additions & 0 deletions Lib/test/test_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -5867,6 +5867,12 @@ def foo(a: 'Node[T'):
with self.assertRaises(SyntaxError):
get_type_hints(foo)

def test_syntax_error_empty_string(self):
for form in [typing.List, typing.Set, typing.Type, typing.Deque]:
with self.subTest(form=form):
with self.assertRaises(SyntaxError):
form['']

def test_name_error(self):

def foo(a: 'Noode[T]'):
Expand Down
2 changes: 1 addition & 1 deletion Lib/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@ def __init__(self, arg, is_argument=True, module=None, *, is_class=False):
# If we do `def f(*args: *Ts)`, then we'll have `arg = '*Ts'`.
# Unfortunately, this isn't a valid expression on its own, so we
# do the unpacking manually.
if arg[0] == '*':
if arg.startswith('*'):
arg_to_compile = f'({arg},)[0]' # E.g. (*Ts,)[0] or (*tuple[int, int],)[0]
else:
arg_to_compile = arg
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Get WASI builds to work under wasmtime 18 w/ WASI 0.2/preview2 primitives.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
:mod:`typing`: raise :exc:`SyntaxError` instead of :exc:`AttributeError`
on forward references as empty strings.
Loading

0 comments on commit dad9100

Please sign in to comment.