From 05a15c8b621f953607429f3b67e079dfe1b439d6 Mon Sep 17 00:00:00 2001 From: Charles Harris Date: Thu, 11 Jul 2013 20:29:08 -0600 Subject: MAINT: Remove uses of the WarningManager class. WarningManager was a workaround for the lack of the with statement in Python versions < 2.6. As those versions are no longer supported it can be removed. Deprecation notes are added to WarningManager and WarningMessage, but to avoid a cascade of messages in third party apps, no warnings are raised at this time, that can be done later. Closes #3519. --- numpy/lib/utils.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'numpy/lib/utils.py') diff --git a/numpy/lib/utils.py b/numpy/lib/utils.py index f19a47176..f54946722 100644 --- a/numpy/lib/utils.py +++ b/numpy/lib/utils.py @@ -1107,18 +1107,14 @@ def safe_eval(source): """ # Local imports to speed up numpy's import time. import warnings - from numpy.testing.utils import WarningManager - warn_ctx = WarningManager() - warn_ctx.__enter__() - try: + + with warnings.catch_warnings(): # compiler package is deprecated for 3.x, which is already solved here warnings.simplefilter('ignore', DeprecationWarning) try: import compiler except ImportError: import ast as compiler - finally: - warn_ctx.__exit__() walker = SafeEval() try: -- cgit v1.2.1