summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2008-12-29 02:44:38 +0000
committerZac Medico <zmedico@gentoo.org>2008-12-29 02:44:38 +0000
commite14eb85f8495e4a1e273ef17ad10867c353a76bf (patch)
treea50b7f3c1a8cf5e7c1987bcef096094f34749c1a
parent1bf79092b6bda1489893c1846a57e57f5e2ef430 (diff)
downloadportage-e14eb85f8495e4a1e273ef17ad10867c353a76bf.tar.gz
portage-e14eb85f8495e4a1e273ef17ad10867c353a76bf.tar.bz2
portage-e14eb85f8495e4a1e273ef17ad10867c353a76bf.zip
Bug #252840 - Fix TypeError which is triggered by a broken override of
varnings.formatwarning(). Override warnings.showwarning() instead since the api docs say it may be overriden while they do not say this about formatwarning(). svn path=/main/trunk/; revision=12363
-rw-r--r--pym/portage_compat_namespace.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/pym/portage_compat_namespace.py b/pym/portage_compat_namespace.py
index 07f22a95e..6956ec2b3 100644
--- a/pym/portage_compat_namespace.py
+++ b/pym/portage_compat_namespace.py
@@ -31,10 +31,15 @@ try:
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