1 |
Author: zmedico |
2 |
Date: 2010-01-05 19:15:39 +0000 (Tue, 05 Jan 2010) |
3 |
New Revision: 15169 |
4 |
|
5 |
Modified: |
6 |
main/trunk/pym/portage/exception.py |
7 |
Log: |
8 |
In python-2.x, convert PortageException.value attribute from unicode to str |
9 |
in order to avoid empty output with string format operator. |
10 |
|
11 |
|
12 |
Modified: main/trunk/pym/portage/exception.py |
13 |
=================================================================== |
14 |
--- main/trunk/pym/portage/exception.py 2010-01-05 19:02:44 UTC (rev 15168) |
15 |
+++ main/trunk/pym/portage/exception.py 2010-01-05 19:15:39 UTC (rev 15169) |
16 |
@@ -3,6 +3,7 @@ |
17 |
# $Id$ |
18 |
|
19 |
import sys |
20 |
+from portage import _unicode_encode |
21 |
from portage.localization import _ |
22 |
|
23 |
if sys.hexversion >= 0x3000000: |
24 |
@@ -12,6 +13,10 @@ |
25 |
"""General superclass for portage exceptions""" |
26 |
def __init__(self,value): |
27 |
self.value = value[:] |
28 |
+ if sys.hexversion < 0x3000000 and isinstance(self.value, unicode): |
29 |
+ # Workaround for string formatting operator and unicode value |
30 |
+ # attribute triggering empty output in formatted string. |
31 |
+ self.value = _unicode_encode(self.value) |
32 |
def __str__(self): |
33 |
if isinstance(self.value, basestring): |
34 |
return self.value |