Rev 5317: Make trace.py importable in python 3.1. in http://bazaar.launchpad.net/~lifeless/bzr/py3

Robert Collins robertc at robertcollins.net
Tue Jun 22 20:43:24 BST 2010


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

------------------------------------------------------------
revno: 5317
revision-id: robertc at robertcollins.net-20100622194323-k11ty9ga6m7d31q3
parent: robertc at robertcollins.net-20100622193832-qra4qy6jxug500un
committer: Robert Collins <robertc at robertcollins.net>
branch nick: py3
timestamp: Wed 2010-06-23 07:43:23 +1200
message:
  Make trace.py importable in python 3.1.
=== modified file 'bzrlib/trace.py'
--- a/bzrlib/trace.py	2010-06-21 03:15:55 +0000
+++ b/bzrlib/trace.py	2010-06-22 19:43:23 +0000
@@ -257,12 +257,14 @@
             try:
                 fd = os.open(filename, flags)
                 break
-            except OSError, e:
+            except OSError:
+                e = sys.exc_info()[1]
                 if e.errno != errno.ENOENT:
                     raise
             try:
-                fd = os.open(filename, flags | os.O_CREAT | os.O_EXCL, 0666)
-            except OSError, e:
+                fd = os.open(filename, flags | os.O_CREAT | os.O_EXCL, 0o666)
+            except OSError:
+                e = sys.exc_info()[1]
                 if e.errno != errno.EEXIST:
                     raise
             else:
@@ -283,12 +285,13 @@
 
         return bzr_log_file
 
-    except EnvironmentError, e:
+    except EnvironmentError:
         # If we are failing to open the log, then most likely logging has not
         # been set up yet. So we just write to stderr rather than using
         # 'warning()'. If we using warning(), users get the unhelpful 'no
         # handlers registered for "bzr"' when something goes wrong on the
         # server. (bug #503886)
+        e = sys.exc_info()[1]
         sys.stderr.write("failed to open trace file: %s\n" % (e,))
     # TODO: What should happen if we fail to open the trace file?  Maybe the
     # objects should be pointed at /dev/null or the equivalent?  Currently
@@ -364,12 +367,15 @@
     return ('log_memento', old_handlers, new_handler, old_trace_file, to_file)
 
 
-def pop_log_file((magic, old_handlers, new_handler, old_trace_file, new_trace_file)):
+def pop_log_file(log_file_memento):
     """Undo changes to logging/tracing done by _push_log_file.
 
     This flushes, but does not close the trace file.
 
-    Takes the memento returned from _push_log_file."""
+    Takes the memento returned from _push_log_file.
+    """
+    magic, old_handlers, new_handler, old_trace_file, new_trace_file = \
+        log_file_memento
     global _trace_file
     _trace_file = old_trace_file
     bzr_logger = logging.getLogger('bzr')
@@ -544,8 +550,9 @@
     try:
         sys.stdout.flush()
         sys.stderr.flush()
-    except IOError, e:
+    except IOError:
         import errno
+        e = sys.exc_info()[1]
         if e.errno in [errno.EINVAL, errno.EPIPE]:
             pass
         else:




More information about the bazaar-commits mailing list