Gentoo Archives: gentoo-commits

From: "Zac Medico (zmedico)" <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] portage r12363 - main/trunk/pym
Date: Mon, 29 Dec 2008 02:44:41
Message-Id: E1LH87T-0008SX-CB@stork.gentoo.org
1 Author: zmedico
2 Date: 2008-12-29 02:44:38 +0000 (Mon, 29 Dec 2008)
3 New Revision: 12363
4
5 Modified:
6 main/trunk/pym/portage_compat_namespace.py
7 Log:
8 Bug #252840 - Fix TypeError which is triggered by a broken override of
9 varnings.formatwarning(). Override warnings.showwarning() instead since
10 the api docs say it may be overriden while they do not say this about
11 formatwarning().
12
13
14 Modified: main/trunk/pym/portage_compat_namespace.py
15 ===================================================================
16 --- main/trunk/pym/portage_compat_namespace.py 2008-12-28 22:29:51 UTC (rev 12362)
17 +++ main/trunk/pym/portage_compat_namespace.py 2008-12-29 02:44:38 UTC (rev 12363)
18 @@ -31,10 +31,15 @@
19 except (ImportError, AttributeError):
20 raise ImportError("No module named %s" % __oldname)
21
22 -def _formatwarning(message, category, filename, lineno):
23 - return "%s:%s: %s: %s\n" % (filename, lineno, category.__name__, message)
24 +def _showwarning(message, category, filename, lineno, file=None, line=None):
25 + if file is None:
26 + file = sys.stderr
27 + try:
28 + file.write("%s:%s: %s: %s\n" % (filename, lineno, category.__name__, message))
29 + except IOError:
30 + pass
31
32 -warnings.formatwarning = _formatwarning
33 +warnings.showwarning = _showwarning
34
35 warnings.warn("DEPRECATION NOTICE: The %s module was replaced by %s" % (__oldname, __newname), DeprecationWarning)
36 sys.modules[__oldname] = __realmodule