# HG changeset patch
# User Simon Heimberg <[email protected]>
# Date 1312375591 -7200
# Node ID 2d3284ca70533bcda10710e9f7d74af446ef9215
# Parent 4fc3521bcb5aae38bfd06546a67a8a15bb20dc9a
hglib: functions tounicode and fromunicode less error prone
* tounicode returns QString unmodified instead of raising an error. QString is
in unicode already.
* fromunicode returns str unmodified
diff -r 4fc3521bcb5a -r 2d3284ca7053 tortoisehg/util/hglib.py
--- a/tortoisehg/util/hglib.py Mit Aug 03 14:16:09 2011 +0200
+++ b/tortoisehg/util/hglib.py Mit Aug 03 14:46:31 2011 +0200
@@ -86,6 +86,12 @@
return s.decode(e, 'strict')
except UnicodeDecodeError:
pass
+ except AttributeError:
+ if type(s).__name__ = 'QString':
+ # s can be QtCore.QString which is unicode
+ # but does not have decode
+ return s
+ raise
return s.decode(_fallbackencoding, 'replace')
def fromunicode(s, errors='strict'):
@@ -99,6 +105,8 @@
"""
if s is None:
return None
+ if isinstance(s, str):
+ return s
s = unicode(s) # s can be QtCore.QString
for enc in (_encoding, _fallbackencoding):
try:
------------------------------------------------------------------------------
BlackBerry® DevCon Americas, Oct. 18-20, San Francisco, CA
The must-attend event for mobile developers. Connect with experts.
Get tools for creating Super Apps. See the latest technologies.
Sessions, hands-on labs, demos & much more. Register early & save!
http://p.sf.net/sfu/rim-blackberry-1
_______________________________________________
Tortoisehg-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tortoisehg-develop