From a00e9d553d2a96d709162417055bac2436e13c0a Mon Sep 17 00:00:00 2001 From: messense Date: Sat, 16 Jul 2022 03:39:58 +0800 Subject: [PATCH] Update Python to 3.11.0b4 in emscripten test (#2507) * Update Python to 3.11.0b4 in emscripten test * Print traceback when import exception failed * Try `ALLOW_MEMORY_GROWTH=1` --- .github/workflows/ci.yml | 10 +++++----- emscripten/Makefile | 2 +- noxfile.py | 1 + src/exceptions.rs | 8 +++++++- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 04988c89b1b..ef27ab34737 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,7 +19,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: actions/setup-python@v3 + - uses: actions/setup-python@v4 - run: pip install nox - uses: actions-rs/toolchain@v1 with: @@ -35,7 +35,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: actions/setup-python@v3 + - uses: actions/setup-python@v4 - run: pip install nox - uses: actions-rs/toolchain@v1 with: @@ -152,7 +152,7 @@ jobs: - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v3 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} architecture: ${{ matrix.platform.python-architecture }} @@ -324,7 +324,7 @@ jobs: runs-on: ${{ matrix.os }}-latest steps: - uses: actions/checkout@v3 - - uses: actions/setup-python@v3 + - uses: actions/setup-python@v4 with: python-version: "3.10" - uses: Swatinem/rust-cache@v1 @@ -351,7 +351,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 + - uses: actions/setup-python@v4 id: setup-python with: python-version: 3.11-dev diff --git a/emscripten/Makefile b/emscripten/Makefile index eec64876298..650944bd461 100644 --- a/emscripten/Makefile +++ b/emscripten/Makefile @@ -3,7 +3,7 @@ CURDIR=$(abspath .) # These three are passed in from nox. BUILDROOT ?= $(CURDIR)/builddir PYMAJORMINORMICRO ?= 3.11.0 -PYPRERELEASE ?= b1 # I'm not sure how to split 3.11.0b1 in Make. +PYPRERELEASE ?= b4 # I'm not sure how to split 3.11.0b4 in Make. EMSCRIPTEN_VERSION=3.1.13 diff --git a/noxfile.py b/noxfile.py index 12fe0e4b293..7f7e9f8c986 100644 --- a/noxfile.py +++ b/noxfile.py @@ -187,6 +187,7 @@ def test_emscripten(session: nox.Session): f"-C link-arg=-lpython{info.pymajorminor}", "-C link-arg=-lexpat", "-C link-arg=-lmpdec", + "-C link-arg=-sALLOW_MEMORY_GROWTH=1", ] ) session.env["CARGO_BUILD_TARGET"] = target diff --git a/src/exceptions.rs b/src/exceptions.rs index 4a4d60ef6d9..c9543a280a7 100644 --- a/src/exceptions.rs +++ b/src/exceptions.rs @@ -108,7 +108,13 @@ macro_rules! import_exception { .get_or_init(py, || { let imp = py .import(stringify!($module)) - .expect(concat!("Can not import module: ", stringify!($module))); + .unwrap_or_else(|err| { + let traceback = err + .traceback(py) + .map(|tb| tb.format().expect("raised exception will have a traceback")) + .unwrap_or_default(); + ::std::panic!("Can not import module {}: {}\n{}", stringify!($module), err, traceback); + }); let cls = imp.getattr(stringify!($name)).expect(concat!( "Can not load exception class: {}.{}", stringify!($module),