aboutsummaryrefslogtreecommitdiffstats
path: root/libbe/comment.py
diff options
context:
space:
mode:
Diffstat (limited to 'libbe/comment.py')
-rw-r--r--libbe/comment.py15
1 files changed, 7 insertions, 8 deletions
diff --git a/libbe/comment.py b/libbe/comment.py
index 9bef50a..d03f8ce 100644
--- a/libbe/comment.py
+++ b/libbe/comment.py
@@ -256,7 +256,7 @@ class Comment (Tree, settings_object.SavedSettingsObject):
value = getattr(self, setting)
if value == None:
return ""
- if type(value) not in types.StringTypes:
+ if type(value) not in (str,):
return str(value)
return value
@@ -334,7 +334,7 @@ class Comment (Tree, settings_object.SavedSettingsObject):
return istring + sep.join(lines).rstrip('\n')
def from_xml(self, xml_string, preserve_uuids=False):
- u"""
+ """
Note: If alt-id is not given, translates any <uuid> fields to
<alt-id> fields.
>>> commA = Comment(bug=None, body="Some\\ninsightful\\nremarks\\n")
@@ -358,7 +358,7 @@ class Comment (Tree, settings_object.SavedSettingsObject):
>>> commC.uuid == commA.uuid
True
"""
- if type(xml_string) == types.UnicodeType:
+ if type(xml_string) == str:
xml_string = xml_string.strip().encode('unicode_escape')
if hasattr(xml_string, 'getchildren'): # already an ElementTree Element
comment = xml_string
@@ -381,7 +381,7 @@ class Comment (Tree, settings_object.SavedSettingsObject):
text = settings_object.EMPTY
else:
text = xml.sax.saxutils.unescape(child.text)
- if not isinstance(text, unicode):
+ if not isinstance(text, str):
text = text.decode('unicode_escape')
text = text.strip()
if child.tag == 'uuid' and not preserve_uuids:
@@ -481,9 +481,8 @@ class Comment (Tree, settings_object.SavedSettingsObject):
if accept_extra_strings == True:
self.extra_strings.append(estr)
elif change_exception == True:
- raise ValueError, \
- 'Merge would add extra string "%s" to comment %s' \
- % (estr, self.uuid)
+ raise ValueError('Merge would add extra string "%s" to comment %s' \
+ % (estr, self.uuid))
def string(self, indent=0):
"""
@@ -613,7 +612,7 @@ class Comment (Tree, settings_object.SavedSettingsObject):
self.id.storage('values'), '{}\n')
try:
settings = mapfile.parse(settings_mapfile)
- except mapfile.InvalidMapfileContents, e:
+ except mapfile.InvalidMapfileContents as e:
raise Exception('Invalid settings file for comment %s\n'
'(BE version missmatch?)' % self.id.user())
self._setup_saved_settings(settings)