-
- Downloads
py: Allow builtins to be overridden.
This patch adds a configuration option (MICROPY_CAN_OVERRIDE_BUILTINS) which, when enabled, allows to override all names within the builtins module. A builtins override dict is created the first time the user assigns to a name in the builtins model, and then that dict is searched first on subsequent lookups. Note that this implementation doesn't allow deleting of names. This patch also does some refactoring of builtins code, creating the modbuiltins.c file. Addresses issue #959.
Showing
- py/builtin.h 4 additions, 0 deletionspy/builtin.h
- py/builtinimport.c 9 additions, 2 deletionspy/builtinimport.c
- py/builtintables.c 0 additions, 261 deletionspy/builtintables.c
- py/builtintables.h 0 additions, 32 deletionspy/builtintables.h
- py/modbuiltins.c 128 additions, 0 deletionspy/modbuiltins.c
- py/mpconfig.h 5 additions, 0 deletionspy/mpconfig.h
- py/obj.h 10 additions, 1 deletionpy/obj.h
- py/objmodule.c 82 additions, 4 deletionspy/objmodule.c
- py/py.mk 1 addition, 2 deletionspy/py.mk
- py/runtime.c 28 additions, 5 deletionspy/runtime.c
- stmhal/mpconfigport.h 1 addition, 0 deletionsstmhal/mpconfigport.h
- tests/basics/builtin_override.py 13 additions, 0 deletionstests/basics/builtin_override.py
- unix/mpconfigport.h 1 addition, 0 deletionsunix/mpconfigport.h
- windows/mpconfigport.h 1 addition, 0 deletionswindows/mpconfigport.h
py/builtintables.c
deleted
100644 → 0
py/builtintables.h
deleted
100644 → 0
tests/basics/builtin_override.py
0 → 100644
Please register or sign in to comment