Windows exceptions not handled when locking working tree

Bug #572201 reported by Simon Kersey
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Bazaar
Fix Released
Undecided
Martin Packman
Python for Windows Extensions
Unknown
Unknown

Bug Description

In attempting to fix a bug reported on BzrExplorer (Bug 568728) I came across an issue with exception handling across different platforms.

The bug exhibited itself when a working tree displayed in Explorer was renamed or deleted using the OS and the repository tab in Explorer was refreshed.

On Windows an unhandled exception was displayed for a pywintypes.error with a stack dump for "File "bzrlib\lock.pyo", line 352, in _open error: (3, 'CreateFileW', 'The system cannot find the path specified.')" caused by qbzr attempting to obtain a lock on a working tree that no longer exists.

Review comments on a qbzr patch to fix the problem indicated that on UBUNTU a 'friendly' dialog is displayed rather than an unhandled exception. This is managed by qbzr and relies on the return from bzrlib.trace.report_exception() being less than bzrlib.errors.EXIT_INTERNAL_ERROR to detect that a more friendly message should be shown.

The bug in bzr is that it does not handle the Windows specific errors in away that allows them to be treated generically downstream.

Related branches

Revision history for this message
Martin Pool (mbp) wrote :

Perhaps pywintypes.error should be treated the same as OSError in report_exception?

tags: added: easy traceback win32
Revision history for this message
Alexander Belchenko (bialix) wrote :

In this particular case pywintypes.error comes from pywin32 package and it's indeed equivalent of OSError (WindowsError).

Revision history for this message
Martin Packman (gz) wrote :

Ah, okay, so an OSError is considered the user's fault, and reported differently to other kinds of exception? If the right fix is just treating this error as not-internal, I can do that.

In a sense this is an upstream bug as pywin32 should throw WindowsError from win32 functions like ctypes, or at least their exception type should be derived from WindowsError rather than plain Exception.

Changed in bzr:
assignee: nobody → Martin [gz] (gz)
status: New → In Progress
Revision history for this message
Martin Packman (gz) wrote :

Workaround landed in r5246, will try and do prettier formatting later as well.

Changed in bzr:
status: In Progress → Fix Released
Vincent Ladeuil (vila)
Changed in bzr:
milestone: none → 2.2b3
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.