summaryrefslogtreecommitdiffstats
path: root/pym/portage_compat_namespace.py
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2009-01-12 08:06:04 +0000
committerZac Medico <zmedico@gentoo.org>2009-01-12 08:06:04 +0000
commitd6132b43d2c29a2783ea9aab83c29a7d84e37f97 (patch)
tree769a1c9ba9341c3a81b113067ba27e1938ecc077 /pym/portage_compat_namespace.py
parent47001eabf7191d217cc0fc7412d49bb919aff476 (diff)
downloadportage-d6132b43d2c29a2783ea9aab83c29a7d84e37f97.tar.gz
portage-d6132b43d2c29a2783ea9aab83c29a7d84e37f97.tar.bz2
portage-d6132b43d2c29a2783ea9aab83c29a7d84e37f97.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(). (trunk r12363) svn path=/main/branches/2.1.6/; revision=12434
Diffstat (limited to 'pym/portage_compat_namespace.py')
-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