Skip to content

dir() inside class property/method causes board reset #8360

@michalpokusa

Description

@michalpokusa

CircuitPython version

Adafruit CircuitPython 8.2.4 on 2023-08-22; Adafruit Feather ESP32-S2 TFT with ESP32S2
Board ID:adafruit_feather_esp32s2_tft
UID:487F305FFE63

Code/REPL

class SimpleClass:

    def __init__(
        self,
        param1: int,
        param2: str,
    ):
        self.param1 = param1
        self.param2 = param2

    @property
    def property1(self):
        print(dir(self)) # <-- This is the line that causes the board to crash
        return (self.param1, self.param2)

    def some_func(self):
        print(dir(self)) # <-- This is the line that causes the board to crash



input("Press Enter to start...")

simple_object = SimpleClass(1, "2")
# print(dir(simple_object)) # <-- If dir() called outside, no crash
simple_object.property1
simple_object.some_func()

Behavior

Board crashed every time it reaches the dir(self), no output, simply the sound of USB device disconnected and then after a few secodns connected again

Description

  • if the dir() is inside a property or a method, it crashes the board
  • if the dir() is called outside a class, it works as expected
  • in CPython it works as expected

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions