Rev 5318: Make lazy_import importable in Python 3.1. in http://bazaar.launchpad.net/~lifeless/bzr/py3

Robert Collins robertc at robertcollins.net
Tue Jun 22 20:48:53 BST 2010


At http://bazaar.launchpad.net/~lifeless/bzr/py3

------------------------------------------------------------
revno: 5318
revision-id: robertc at robertcollins.net-20100622194851-6swtleokl4ihoo9p
parent: robertc at robertcollins.net-20100622194323-k11ty9ga6m7d31q3
committer: Robert Collins <robertc at robertcollins.net>
branch nick: py3
timestamp: Wed 2010-06-23 07:48:51 +1200
message:
  Make lazy_import importable in Python 3.1.
=== modified file 'bzrlib/lazy_import.py'
--- a/bzrlib/lazy_import.py	2009-03-23 14:59:43 +0000
+++ b/bzrlib/lazy_import.py	2010-06-22 19:48:51 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2006 Canonical Ltd
+# Copyright (C) 2006, 2010 Canonical Ltd
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -76,12 +76,13 @@
         try:
             factory = object.__getattribute__(self, '_factory')
             scope = object.__getattribute__(self, '_scope')
-        except AttributeError, e:
+        except AttributeError:
             # Because ScopeReplacer objects only replace a single
             # item, passing them to another variable before they are
             # replaced would cause them to keep getting replaced
             # (only they are replacing the wrong variable). So we
             # make it forbidden, and try to give a good error.
+            e = sys.exc_info()[1]
             raise errors.IllegalUseOfScopeReplacer(
                 name, msg="Object already cleaned up, did you assign it"
                           " to another variable?",
@@ -198,7 +199,7 @@
 
         # Prepare the children to be imported
         for child_name, (child_path, child_member, grandchildren) in \
-                children.iteritems():
+                children.items():
             # Using self.__class__, so that children get children classes
             # instantiated. (This helps with instrumented tests)
             cls = object.__getattribute__(self, '__class__')
@@ -237,7 +238,7 @@
 
     def _convert_imports(self, scope):
         # Now convert the map into a set of imports
-        for name, info in self.imports.iteritems():
+        for name, info in self.imports.items():
             self._lazy_import_class(scope, name=name, module_path=info[0],
                                     member=info[1], children=info[2])
 




More information about the bazaar-commits mailing list