except (ImportError, AttributeError):
raise ImportError("No module named %s" % __oldname)
-def _formatwarning(message, category, filename, lineno):
- return "%s:%s: %s: %s\n" % (filename, lineno, category.__name__, message)
-
-warnings.formatwarning = _formatwarning
+def _showwarning(message, category, filename, lineno, file=None, line=None):
+ if file is None:
+ file = sys.stderr
+ try:
+ file.write("%s:%s: %s: %s\n" % (filename, lineno, category.__name__, message))
+ except IOError:
+ pass
+
+warnings.showwarning = _showwarning
warnings.warn("DEPRECATION NOTICE: The %s module was replaced by %s" % (__oldname, __newname), DeprecationWarning)
sys.modules[__oldname] = __realmodule