summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ports/esp8266/mpconfigport.h1
-rw-r--r--py/modsys.c14
-rw-r--r--py/mpconfig.h2
-rw-r--r--py/mpstate.h3
4 files changed, 18 insertions, 2 deletions
diff --git a/ports/esp8266/mpconfigport.h b/ports/esp8266/mpconfigport.h
index 37a794f44..18b2e47e2 100644
--- a/ports/esp8266/mpconfigport.h
+++ b/ports/esp8266/mpconfigport.h
@@ -19,7 +19,6 @@
#define MICROPY_OPT_MATH_FACTORIAL (0)
#define MICROPY_REPL_EMACS_KEYS (0)
#define MICROPY_PY_BUILTINS_COMPLEX (0)
-#define MICROPY_MODULE_ATTR_DELEGATION (0)
#define MICROPY_PY_FUNCTION_ATTRS (0)
#define MICROPY_PY_DELATTR_SETATTR (0)
#define MICROPY_PY_BUILTINS_STR_CENTER (0)
diff --git a/py/modsys.c b/py/modsys.c
index a0ecb87b5..72817ce00 100644
--- a/py/modsys.c
+++ b/py/modsys.c
@@ -195,7 +195,21 @@ STATIC mp_obj_t mp_sys_settrace(mp_obj_t obj) {
MP_DEFINE_CONST_FUN_OBJ_1(mp_sys_settrace_obj, mp_sys_settrace);
#endif // MICROPY_PY_SYS_SETTRACE
+
+#if MICROPY_PY_SYS_PS1_PS2 && !MICROPY_PY_SYS_ATTR_DELEGATION
+#error "MICROPY_PY_SYS_PS1_PS2 requires MICROPY_PY_SYS_ATTR_DELEGATION"
+#endif
+
+#if MICROPY_PY_SYS_TRACEBACKLIMIT && !MICROPY_PY_SYS_ATTR_DELEGATION
+#error "MICROPY_PY_SYS_TRACEBACKLIMIT requires MICROPY_PY_SYS_ATTR_DELEGATION"
+#endif
+
+#if MICROPY_PY_SYS_ATTR_DELEGATION && !MICROPY_MODULE_ATTR_DELEGATION
+#error "MICROPY_PY_SYS_ATTR_DELEGATION requires MICROPY_MODULE_ATTR_DELEGATION"
+#endif
+
#if MICROPY_PY_SYS_ATTR_DELEGATION
+// Must be kept in sync with the enum at the top of mpstate.h.
STATIC const uint16_t sys_mutable_keys[] = {
#if MICROPY_PY_SYS_PS1_PS2
MP_QSTR_ps1,
diff --git a/py/mpconfig.h b/py/mpconfig.h
index 504ad64b0..b6f883866 100644
--- a/py/mpconfig.h
+++ b/py/mpconfig.h
@@ -842,7 +842,7 @@ typedef double mp_float_t;
// Whether modules can use MP_REGISTER_MODULE_DELEGATION() to delegate failed
// attribute lookups to a custom handler function.
#ifndef MICROPY_MODULE_ATTR_DELEGATION
-#define MICROPY_MODULE_ATTR_DELEGATION (MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
+#define MICROPY_MODULE_ATTR_DELEGATION (MICROPY_PY_SYS_ATTR_DELEGATION || MICROPY_CONFIG_ROM_LEVEL_AT_LEAST_EXTRA_FEATURES)
#endif
// Whether to call __init__ when importing builtin modules for the first time.
diff --git a/py/mpstate.h b/py/mpstate.h
index 80b49cb6b..3786131de 100644
--- a/py/mpstate.h
+++ b/py/mpstate.h
@@ -40,6 +40,8 @@
// memory system, runtime and virtual machine. The state is a global
// variable, but in the future it is hoped that the state can become local.
+#if MICROPY_PY_SYS_ATTR_DELEGATION
+// Must be kept in sync with sys_mutable_keys in modsys.c.
enum {
#if MICROPY_PY_SYS_PS1_PS2
MP_SYS_MUTABLE_PS1,
@@ -50,6 +52,7 @@ enum {
#endif
MP_SYS_MUTABLE_NUM,
};
+#endif // MICROPY_PY_SYS_ATTR_DELEGATION
// This structure contains dynamic configuration for the compiler.
#if MICROPY_DYNAMIC_COMPILER