From 2f5d113fad4ca2b22b084ccaf835c595cd6a7a4e Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Fri, 21 Dec 2018 14:20:55 +0300 Subject: py/warning: Support categories for warnings. Python defines warnings as belonging to categories, where category is a warning type (descending from exception type). This is useful, as e.g. allows to disable warnings selectively and provide user-defined warning types. So, implement this in MicroPython, except that categories are represented just with strings. However, enough hooks are left to implement categories differently per-port (e.g. as types), without need to patch each and every usage. --- py/obj.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'py/obj.c') diff --git a/py/obj.c b/py/obj.c index 47b7d15ae..7007d5070 100644 --- a/py/obj.c +++ b/py/obj.c @@ -202,7 +202,7 @@ bool mp_obj_equal(mp_obj_t o1, mp_obj_t o2) { str_cmp_err: #if MICROPY_PY_STR_BYTES_CMP_WARN if (MP_OBJ_IS_TYPE(o1, &mp_type_bytes) || MP_OBJ_IS_TYPE(o2, &mp_type_bytes)) { - mp_warning("Comparison between bytes and str"); + mp_warning(MP_WARN_CAT(BytesWarning), "Comparison between bytes and str"); } #endif return false; -- cgit v1.2.3