Rev 5239: Workaround a bug (#582656) in recent versions of Pyrex. in http://bazaar.launchpad.net/~jameinel/bzr/pyrex_099

John Arbash Meinel john at arbash-meinel.com
Wed May 19 17:58:42 BST 2010


At http://bazaar.launchpad.net/~jameinel/bzr/pyrex_099

------------------------------------------------------------
revno: 5239
revision-id: john at arbash-meinel.com-20100519165839-6el8cg5jnb1i0wsm
parent: pqm at pqm.ubuntu.com-20100518024615-dmqzcnicw5p48k53
fixes bug(s): https://launchpad.net/bugs/582656
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: pyrex_099
timestamp: Wed 2010-05-19 11:58:39 -0500
message:
  Workaround a bug (#582656) in recent versions of Pyrex.
  
  It seems that if you use:
    except Exception: 
  Recent versions of Pyrex (0.9.8.6? and 0.9.9) leave the exception state set.
  Which means that if in the except: clause you have something like object comparison
  it checks PyErr_Occurred and then re-raises the exception you were trapping.
  The workaround is to always use:
    except Exception, e:
  style syntax.
  
  I used 'except Exception, _:' to make it clear we weren't touching the error,
  and because there was a place or two where we *were* making use of a variable
  named 'e' (caught by a different exception path).
-------------- next part --------------
=== modified file 'bzrlib/_dirstate_helpers_pyx.pyx'
--- a/bzrlib/_dirstate_helpers_pyx.pyx	2010-02-23 07:43:11 +0000
+++ b/bzrlib/_dirstate_helpers_pyx.pyx	2010-05-19 16:58:39 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2007, 2008, 2010 Canonical Ltd
+# Copyright (C) 2007-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
@@ -110,6 +110,8 @@
     void Py_INCREF(object o)
     void Py_DECREF(object o)
 
+    void PyErr_Clear()
+
 
 cdef extern from "string.h":
     int strncmp(char *s1, char *s2, int len)
@@ -1219,7 +1221,7 @@
             else:
                 try:
                     source_parent_id = self.old_dirname_to_file_id[old_dirname]
-                except KeyError:
+                except KeyError, _:
                     source_parent_entry = self.state._get_entry(self.source_index,
                                                            path_utf8=old_dirname)
                     source_parent_id = source_parent_entry[0][2]
@@ -1236,7 +1238,7 @@
             else:
                 try:
                     target_parent_id = self.new_dirname_to_file_id[new_dirname]
-                except KeyError:
+                except KeyError, _:
                     # TODO: We don't always need to do the lookup, because the
                     #       parent entry will be the same as the source entry.
                     target_parent_entry = self.state._get_entry(self.target_index,
@@ -1478,7 +1480,7 @@
             # interface doesn't require it.
             try:
                 self.current_root = self.search_specific_files.pop()
-            except KeyError:
+            except KeyError, _:
                 raise StopIteration()
             self.searched_specific_files.add(self.current_root)
             # process the entries for this containing directory: the rest will be
@@ -1567,7 +1569,7 @@
                         #            and e.winerror == ERROR_DIRECTORY
                         try:
                             e_winerror = e.winerror
-                        except AttributeError:
+                        except AttributeError, _:
                             e_winerror = None
                         win_errors = (ERROR_DIRECTORY, ERROR_PATH_NOT_FOUND)
                         if (e.errno in win_errors or e_winerror in win_errors):
@@ -1656,7 +1658,7 @@
                     try:
                         self.current_dir_info = self.dir_iterator.next()
                         self.current_dir_list = self.current_dir_info[1]
-                    except StopIteration:
+                    except StopIteration, _:
                         self.current_dir_info = None
                 else: #(dircmp > 0)
                     # We have a dirblock entry for this location, but there
@@ -1803,7 +1805,7 @@
                                 and stat.S_IEXEC & current_path_info[3].st_mode)
                             try:
                                 relpath_unicode = self.utf8_decode(current_path_info[0])[0]
-                            except UnicodeDecodeError:
+                            except UnicodeDecodeError, _:
                                 raise errors.BadFilenameEncoding(
                                     current_path_info[0], osutils._fs_enc)
                             if changed is not None:
@@ -1851,7 +1853,7 @@
                 try:
                     self.current_dir_info = self.dir_iterator.next()
                     self.current_dir_list = self.current_dir_info[1]
-                except StopIteration:
+                except StopIteration, _:
                     self.current_dir_info = None
 
     cdef object _next_consistent_entries(self):



More information about the bazaar-commits mailing list