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.
This commit is contained in:
Paul Sokolovsky
2018-12-21 14:20:55 +03:00
committed by Damien George
parent 86f06d6a87
commit 2f5d113fad
8 changed files with 32 additions and 8 deletions

View File

@@ -1116,7 +1116,7 @@ unwind_return:
mp_uint_t unum = *ip;
mp_obj_t obj;
if (unum == 2) {
mp_warning("exception chaining not supported");
mp_warning(NULL, "exception chaining not supported");
// ignore (pop) "from" argument
sp--;
}