Author: Carl Friedrich Bolz-Tereick <cfb...@gmx.de> Branch: py3.7 Changeset: r98607:66293dfd6fd3 Date: 2020-01-30 15:41 +0100 http://bitbucket.org/pypy/pypy/changeset/66293dfd6fd3/
Log: make get/set_coroutine_wrapper emit a DeprecationWarning diff --git a/pypy/interpreter/test/apptest_coroutine.py b/pypy/interpreter/test/apptest_coroutine.py --- a/pypy/interpreter/test/apptest_coroutine.py +++ b/pypy/interpreter/test/apptest_coroutine.py @@ -123,6 +123,18 @@ sys.set_coroutine_wrapper(None) assert sys.get_coroutine_wrapper() is None +def test_get_set_coroutine_wrapper_deprecated(): + import warnings + def my_wrapper(cr): + return 1 + with warnings.catch_warnings(record=True) as l: + warnings.simplefilter('always', category=DeprecationWarning) + sys.get_coroutine_wrapper() + sys.set_coroutine_wrapper(my_wrapper) + sys.set_coroutine_wrapper(None) + print(l) + assert len(l) == 3 + def test_async_with(): seen = [] class X: diff --git a/pypy/module/sys/vm.py b/pypy/module/sys/vm.py --- a/pypy/module/sys/vm.py +++ b/pypy/module/sys/vm.py @@ -343,12 +343,14 @@ def get_coroutine_wrapper(space): "Return the wrapper for coroutine objects set by sys.set_coroutine_wrapper." + space.warn(space.newtext("get_coroutine_wrapper is deprecated"), space.w_DeprecationWarning) ec = space.getexecutioncontext() if ec.w_coroutine_wrapper_fn is None: return space.w_None return ec.w_coroutine_wrapper_fn def set_coroutine_wrapper(space, w_wrapper): + space.warn(space.newtext("set_coroutine_wrapper is deprecated"), space.w_DeprecationWarning) "Set a wrapper for coroutine objects." ec = space.getexecutioncontext() if space.is_w(w_wrapper, space.w_None): _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit