Skip to content

Clearing a existing dic object leads to Floating point exception #10959

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
xiaxinmeng opened this issue Mar 7, 2023 · 1 comment
Open

Clearing a existing dic object leads to Floating point exception #10959

xiaxinmeng opened this issue Mar 7, 2023 · 1 comment
Labels

Comments

@xiaxinmeng
Copy link

The following 'test.py' produces a crash with the unix port. In this example, we clear the dic when defining the dic, then micropython crashes.

test.py

class S(str):

    def __eq__(self, other):
        d.clear()

    def __hash__(self):
        return hash('test')

d = {S(): 'value'}
'test' in d

Error message:

Floating point exception (core dumped)

The expected output: work well (behavior on CPython 3.10.8)

how to replicate it:

  1. install micropython (unix port)
  2. run it with unix port
  3. ->> 'micropython/ports/unix/build-standard/micropython' test.py

Environment
compiler versions: MicroPython v1.19.1-724-gfb7d21153 on 2023-03-07; linux [GCC 7.5.0] version
operating system: Ubuntu 18.04.6 LTS

@xiaxinmeng xiaxinmeng added the bug label Mar 7, 2023
@peterhinch
Copy link
Contributor

See #9997 also MP differences, in particular:

Subclassing of builtin types is partially implemented, but there may be various differences and compatibility issues with CPython.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants