Commit d4e924b0 authored by Boxiang Sun's avatar Boxiang Sun

add warning tests

parent 32657208
...@@ -901,7 +901,7 @@ _PyWarnings_Init(void) ...@@ -901,7 +901,7 @@ _PyWarnings_Init(void)
if (_filters == NULL) if (_filters == NULL)
return; return;
// Pyston change: let the GC scan the filters // Pyston change: let the GC scan the filters
PyGC_AddPotentialRoot(_filters, sizeof(_filters)); PyGC_AddPotentialRoot(&_filters, sizeof(_filters));
Py_INCREF(_filters); Py_INCREF(_filters);
if (PyModule_AddObject(m, "filters", _filters) < 0) if (PyModule_AddObject(m, "filters", _filters) < 0)
return; return;
...@@ -910,7 +910,7 @@ _PyWarnings_Init(void) ...@@ -910,7 +910,7 @@ _PyWarnings_Init(void)
if (_once_registry == NULL) if (_once_registry == NULL)
return; return;
// Pyston change: let the GC scan the registry // Pyston change: let the GC scan the registry
PyGC_AddPotentialRoot(_once_registry, sizeof(_once_registry)); PyGC_AddPotentialRoot(&_once_registry, sizeof(_once_registry));
Py_INCREF(_once_registry); Py_INCREF(_once_registry);
if (PyModule_AddObject(m, "once_registry", _once_registry) < 0) if (PyModule_AddObject(m, "once_registry", _once_registry) < 0)
return; return;
...@@ -919,7 +919,7 @@ _PyWarnings_Init(void) ...@@ -919,7 +919,7 @@ _PyWarnings_Init(void)
if (_default_action == NULL) if (_default_action == NULL)
return; return;
// Pyston change: let the GC scan the action // Pyston change: let the GC scan the action
PyGC_AddPotentialRoot(_default_action, sizeof(_default_action)); PyGC_AddPotentialRoot(&_default_action, sizeof(_default_action));
Py_INCREF(_default_action); Py_INCREF(_default_action);
if (PyModule_AddObject(m, "default_action", _default_action) < 0) if (PyModule_AddObject(m, "default_action", _default_action) < 0)
return; return;
......
import warnings import warnings
import _warnings
# Specifying this as a DeprecationWarning is a hacky way of supressing the warning, warnings.filterwarnings('error')
# since we don't output the exact same error message as CPython right now:
warnings.warn("hello world", DeprecationWarning) try:
warnings.warn("hello world", Warning)
except Warning as w:
print(w.args[0])
try:
_warnings.warn("deperecated", Warning)
except Warning as w:
print(w.args[0])
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment