From 4bcc424f4dc8c908de51e0db3fcf756969c34282 Mon Sep 17 00:00:00 2001 From: eightycc Date: Tue, 18 Mar 2025 09:13:46 -0700 Subject: [PATCH 1/3] Remove CIRCUITPY_8_9_WARNINGS and its usage. --- py/circuitpy_mpconfig.h | 6 ------ py/objmodule.c | 27 --------------------------- 2 files changed, 33 deletions(-) diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index 4d366a37c7fab..49e05e7689d29 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -17,12 +17,6 @@ // Always 1: defined in circuitpy_mpconfig.mk // #define CIRCUITPY (1) -// Can be removed once CircuitPython 10 is released. -// Print warnings or not about deprecated names. See objmodule.c. -#ifndef CIRCUITPY_8_9_WARNINGS -#define CIRCUITPY_8_9_WARNINGS (0) -#endif - // REPR_C encodes qstrs, 31-bit ints, and 30-bit floats in a single 32-bit word. #ifndef MICROPY_OBJ_REPR #define MICROPY_OBJ_REPR (MICROPY_OBJ_REPR_C) diff --git a/py/objmodule.c b/py/objmodule.c index 881ab5e6b254f..3ccd31b23af22 100644 --- a/py/objmodule.c +++ b/py/objmodule.c @@ -67,33 +67,6 @@ static void module_attr_try_delegation(mp_obj_t self_in, qstr attr, mp_obj_t *de static void module_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { mp_obj_module_t *self = MP_OBJ_TO_PTR(self_in); if (dest[0] == MP_OBJ_NULL) { - // CIRCUITPY-CHANGE - #if CIRCUITPY_8_9_WARNINGS && CIRCUITPY_DISPLAYIO && CIRCUITPY_WARNINGS - if (self == &displayio_module) { - #if CIRCUITPY_BUSDISPLAY - if (attr == MP_QSTR_Display) { - warnings_warn(&mp_type_FutureWarning, MP_ERROR_TEXT("%q moved from %q to %q"), MP_QSTR_Display, MP_QSTR_displayio, MP_QSTR_busdisplay); - warnings_warn(&mp_type_FutureWarning, MP_ERROR_TEXT("%q renamed %q"), MP_QSTR_Display, MP_QSTR_BusDisplay); - } - #endif - #if CIRCUITPY_EPAPERDISPLAY - if (attr == MP_QSTR_EPaperDisplay) { - warnings_warn(&mp_type_FutureWarning, MP_ERROR_TEXT("%q moved from %q to %q"), MP_QSTR_EPaperDisplay, MP_QSTR_displayio, MP_QSTR_epaperdisplay); - } - #endif - #if CIRCUITPY_FOURWIRE - if (attr == MP_QSTR_FourWire) { - warnings_warn(&mp_type_FutureWarning, MP_ERROR_TEXT("%q moved from %q to %q"), MP_QSTR_FourWire, MP_QSTR_displayio, MP_QSTR_fourwire); - } - #endif - #if CIRCUITPY_I2CDISPLAYBUS - if (attr == MP_QSTR_I2CDisplay) { - warnings_warn(&mp_type_FutureWarning, MP_ERROR_TEXT("%q moved from %q to %q"), MP_QSTR_I2CDisplay, MP_QSTR_displayio, MP_QSTR_i2cdisplaybus); - warnings_warn(&mp_type_FutureWarning, MP_ERROR_TEXT("%q renamed %q"), MP_QSTR_I2CDisplay, MP_QSTR_I2CDisplayBus); - } - #endif - } - #endif // load attribute mp_map_elem_t *elem = mp_map_lookup(&self->globals->map, MP_OBJ_NEW_QSTR(attr), MP_MAP_LOOKUP); if (elem != NULL) { From 7c827c7e8e469885a7aa9da807dc644f035a4fae Mon Sep 17 00:00:00 2001 From: eightycc Date: Tue, 18 Mar 2025 15:22:03 -0700 Subject: [PATCH 2/3] Revert "Remove CIRCUITPY_8_9_WARNINGS and its usage." This reverts commit 4bcc424f4dc8c908de51e0db3fcf756969c34282. --- py/circuitpy_mpconfig.h | 6 ++++++ py/objmodule.c | 27 +++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index 49e05e7689d29..4d366a37c7fab 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -17,6 +17,12 @@ // Always 1: defined in circuitpy_mpconfig.mk // #define CIRCUITPY (1) +// Can be removed once CircuitPython 10 is released. +// Print warnings or not about deprecated names. See objmodule.c. +#ifndef CIRCUITPY_8_9_WARNINGS +#define CIRCUITPY_8_9_WARNINGS (0) +#endif + // REPR_C encodes qstrs, 31-bit ints, and 30-bit floats in a single 32-bit word. #ifndef MICROPY_OBJ_REPR #define MICROPY_OBJ_REPR (MICROPY_OBJ_REPR_C) diff --git a/py/objmodule.c b/py/objmodule.c index 3ccd31b23af22..881ab5e6b254f 100644 --- a/py/objmodule.c +++ b/py/objmodule.c @@ -67,6 +67,33 @@ static void module_attr_try_delegation(mp_obj_t self_in, qstr attr, mp_obj_t *de static void module_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { mp_obj_module_t *self = MP_OBJ_TO_PTR(self_in); if (dest[0] == MP_OBJ_NULL) { + // CIRCUITPY-CHANGE + #if CIRCUITPY_8_9_WARNINGS && CIRCUITPY_DISPLAYIO && CIRCUITPY_WARNINGS + if (self == &displayio_module) { + #if CIRCUITPY_BUSDISPLAY + if (attr == MP_QSTR_Display) { + warnings_warn(&mp_type_FutureWarning, MP_ERROR_TEXT("%q moved from %q to %q"), MP_QSTR_Display, MP_QSTR_displayio, MP_QSTR_busdisplay); + warnings_warn(&mp_type_FutureWarning, MP_ERROR_TEXT("%q renamed %q"), MP_QSTR_Display, MP_QSTR_BusDisplay); + } + #endif + #if CIRCUITPY_EPAPERDISPLAY + if (attr == MP_QSTR_EPaperDisplay) { + warnings_warn(&mp_type_FutureWarning, MP_ERROR_TEXT("%q moved from %q to %q"), MP_QSTR_EPaperDisplay, MP_QSTR_displayio, MP_QSTR_epaperdisplay); + } + #endif + #if CIRCUITPY_FOURWIRE + if (attr == MP_QSTR_FourWire) { + warnings_warn(&mp_type_FutureWarning, MP_ERROR_TEXT("%q moved from %q to %q"), MP_QSTR_FourWire, MP_QSTR_displayio, MP_QSTR_fourwire); + } + #endif + #if CIRCUITPY_I2CDISPLAYBUS + if (attr == MP_QSTR_I2CDisplay) { + warnings_warn(&mp_type_FutureWarning, MP_ERROR_TEXT("%q moved from %q to %q"), MP_QSTR_I2CDisplay, MP_QSTR_displayio, MP_QSTR_i2cdisplaybus); + warnings_warn(&mp_type_FutureWarning, MP_ERROR_TEXT("%q renamed %q"), MP_QSTR_I2CDisplay, MP_QSTR_I2CDisplayBus); + } + #endif + } + #endif // load attribute mp_map_elem_t *elem = mp_map_lookup(&self->globals->map, MP_OBJ_NEW_QSTR(attr), MP_MAP_LOOKUP); if (elem != NULL) { From aec1071786413c45ca5fc4138fc557869a515e72 Mon Sep 17 00:00:00 2001 From: eightycc Date: Tue, 18 Mar 2025 15:33:43 -0700 Subject: [PATCH 3/3] Rename to CIRCUITPY_9_10_WARNINGS and turn on warnings for CP9. --- py/circuitpy_mpconfig.h | 4 ++-- py/objmodule.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index 4d366a37c7fab..0121144f8ced6 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -19,8 +19,8 @@ // Can be removed once CircuitPython 10 is released. // Print warnings or not about deprecated names. See objmodule.c. -#ifndef CIRCUITPY_8_9_WARNINGS -#define CIRCUITPY_8_9_WARNINGS (0) +#ifndef CIRCUITPY_9_10_WARNINGS +#define CIRCUITPY_9_10_WARNINGS (1) #endif // REPR_C encodes qstrs, 31-bit ints, and 30-bit floats in a single 32-bit word. diff --git a/py/objmodule.c b/py/objmodule.c index 881ab5e6b254f..b6513907e5551 100644 --- a/py/objmodule.c +++ b/py/objmodule.c @@ -68,7 +68,7 @@ static void module_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { mp_obj_module_t *self = MP_OBJ_TO_PTR(self_in); if (dest[0] == MP_OBJ_NULL) { // CIRCUITPY-CHANGE - #if CIRCUITPY_8_9_WARNINGS && CIRCUITPY_DISPLAYIO && CIRCUITPY_WARNINGS + #if CIRCUITPY_9_10_WARNINGS && CIRCUITPY_DISPLAYIO && CIRCUITPY_WARNINGS if (self == &displayio_module) { #if CIRCUITPY_BUSDISPLAY if (attr == MP_QSTR_Display) {