Rev 4809: Document a bit more what 193 means, and why we are testing it. in http://bazaar.launchpad.net/~jameinel/bzr/2.1.0b4-win32-accepted

John Arbash Meinel john at arbash-meinel.com
Tue Nov 17 23:05:09 GMT 2009


At http://bazaar.launchpad.net/~jameinel/bzr/2.1.0b4-win32-accepted

------------------------------------------------------------
revno: 4809
revision-id: john at arbash-meinel.com-20091117230504-p05mbkihim789aq7
parent: john at arbash-meinel.com-20091117230148-rrc2la94nta5tpl8
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.1.0b4-win32-accepted
timestamp: Tue 2009-11-17 17:05:04 -0600
message:
  Document a bit more what 193 means, and why we are testing it.
-------------- next part --------------
=== modified file 'bzrlib/msgeditor.py'
--- a/bzrlib/msgeditor.py	2009-11-17 21:02:01 +0000
+++ b/bzrlib/msgeditor.py	2009-11-17 23:05:04 +0000
@@ -64,6 +64,12 @@
             x = call(edargs + [filename])
         except OSError, e:
             # We're searching for an editor, so catch safe errors and continue
+            # errno 193 is ERROR_BAD_EXE_FORMAT on Windows. Python2.4 uses the
+            # winerror for errno. Python2.5+ use errno ENOEXEC and set winerror
+            # to 193. However, catching 193 here should be fine. Other
+            # platforms aren't likely to have that high of an error. And even
+            # if they do, it is still reasonable to fall back to the next
+            # editor.
             if e.errno in (errno.ENOENT, errno.EACCES, errno.ENOEXEC, 193):
                 if candidate_source is not None:
                     # We tried this editor because some user configuration (an

=== modified file 'bzrlib/tests/test_msgeditor.py'
--- a/bzrlib/tests/test_msgeditor.py	2009-11-17 21:02:53 +0000
+++ b/bzrlib/tests/test_msgeditor.py	2009-11-17 23:05:04 +0000
@@ -373,14 +373,18 @@
 # GZ 2009-11-17: This wants moving to osutils when the errno checking code is
 class TestPlatformErrnoWorkarounds(TestCaseInTempDir):
     """Ensuring workarounds enshrined in code actually serve a purpose"""
-    def test_windows(self):
+
+    def test_subprocess_call_bad_file(self):
         if sys.platform != "win32":
-            raise TestSkipped("Workarounds for windows only")
+            raise TestNotApplicable("Workarounds for windows only")
         import subprocess, errno
         ERROR_BAD_EXE_FORMAT = 193
         file("textfile.txt", "w").close()
         e = self.assertRaises(WindowsError, subprocess.call, "textfile.txt")
-        if sys.version_info > (2, 5):
+        # Python2.4 used the 'winerror' as the errno, which confuses a lot of
+        # our error trapping code. Make sure that we understand the mapping
+        # correctly.
+        if sys.version_info >= (2, 5):
             self.assertEqual(e.errno, errno.ENOEXEC)
             self.assertEqual(e.winerror, ERROR_BAD_EXE_FORMAT)
         else:



More information about the bazaar-commits mailing list