Skip to content

Assertion failed: table.sub_tables.is_empty() when decorator class takes a lambda argument. #4856

Description

@xiaxinmeng

The following code defines two classes, MockedA and MockedB, and uses the mock.patch decorator from the unittest.mock module to patch a function with a lambda function that returns the integer value 3. Then RustPython crashes with an assertion error.

test.py

import unittest
from unittest import mock

class MockedA(BaseFTests):
    pass

@mock.patch("", lambda: 3)
class MockedB(MockedA):
    def _asserts(self, val):
        pass

Crash message:

thread 'main' panicked at 'assertion failed: table.sub_tables.is_empty()', compiler/codegen/src/compile.rs:308:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Environment:
Ubuntu 18.04
rustpython v0.2.0

Activity

  1. youknowone commented on Oct 6, 2026

    @youknowone
    Member

    The originally reported problem no longer reproduces on current main. Closing per the recheck in #8982.

    — commented by Grok 4.6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-compilerArea: compilerC-bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions