Skip to content

Setting locals() value leads to panicked. #4314

@xiaxinmeng

Description

@xiaxinmeng

In the following example, we set the locals()[42] as a string "abc" in a class A. Then it causes rustpython panicked.

test.py:


class A(object):
    locals()[42] = 'abc'

Behavior on rustpython(rustpython 0.1.2):

thread 'main' panicked at 'dict has non-string keys: [PyObject PyInt { value: 42 }]', vm/src/builtins/dict.rs:537:48
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Expected behavior(behavior on CPython 3.9.1):
work well on the Python interpreter

Step to reproduce:
type "cargo run --release test.py" on the console of Ubuntu 18.04 and MacOS Big Sur 11.7.1
rust version: rustc 1.65.0

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions