diff options
Diffstat (limited to 'libbe/bug.py')
-rw-r--r-- | libbe/bug.py | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/libbe/bug.py b/libbe/bug.py index 7b3931d..a4ef53d 100644 --- a/libbe/bug.py +++ b/libbe/bug.py @@ -279,7 +279,7 @@ class Bug (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 @@ -440,7 +440,7 @@ class Bug (settings_object.SavedSettingsObject): return istring + sep.join(lines).rstrip('\n') def from_xml(self, xml_string, preserve_uuids=False): - u""" + """ Note: If a bug uuid is given, set .alt_id to it's value. >>> bugA = Bug(uuid="0123", summary="Need to test Bug.from_xml()") >>> bugA.date = "Thu, 01 Jan 1970 00:00:00 +0000" @@ -469,7 +469,7 @@ class Bug (settings_object.SavedSettingsObject): >>> bugC.uuid == bugA.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 bug = xml_string @@ -497,7 +497,7 @@ class Bug (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: @@ -718,16 +718,15 @@ class Bug (settings_object.SavedSettingsObject): if accept_extra_strings == True: self.extra_strings += [estr] elif change_exception == True: - raise ValueError, \ - 'Merge would add extra string "%s" for bug %s' \ - % (estr, self.uuid) + raise ValueError('Merge would add extra string "%s" for bug %s' \ + % (estr, self.uuid)) for o_comm in other.comments(): try: s_comm = self.comment_root.comment_from_uuid(o_comm.uuid) - except KeyError, e: + except KeyError as e: try: s_comm = self.comment_root.comment_from_uuid(o_comm.alt_id) - except KeyError, e: + except KeyError as e: s_comm = None if s_comm == None: if accept_comments == True: @@ -736,9 +735,8 @@ class Bug (settings_object.SavedSettingsObject): o_comm_copy.id = libbe.util.id.ID(o_comm_copy, 'comment') self.comment_root.add_reply(o_comm_copy) elif change_exception == True: - raise ValueError, \ - 'Merge would add comment %s (alt: %s) to bug %s' \ - % (o_comm.uuid, o_comm.alt_id, self.uuid) + raise ValueError('Merge would add comment %s (alt: %s) to bug %s' \ + % (o_comm.uuid, o_comm.alt_id, self.uuid)) else: s_comm.merge(o_comm, accept_changes=accept_changes, accept_extra_strings=accept_extra_strings, @@ -752,7 +750,7 @@ class Bug (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 bug %s\n' '(BE version missmatch?)' % self.id.user()) self._setup_saved_settings(settings) |