Rev 6458: (jelmer) Correct detection of Python implementations that don't support the in file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/2.5/

Patch Queue Manager pqm at pqm.ubuntu.com
Tue Jan 24 10:22:58 UTC 2012


At file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/2.5/

------------------------------------------------------------
revno: 6458 [merge]
revision-id: pqm at pqm.ubuntu.com-20120124102258-dz7syv2g62srmnpr
parent: pqm at pqm.ubuntu.com-20120123174145-flb09hzz5l5gjods
parent: martin.packman at canonical.com-20120123231145-btq4wqjw27zocag0
committer: Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: 2.5
timestamp: Tue 2012-01-24 10:22:58 +0000
message:
  (jelmer) Correct detection of Python implementations that don't support the
   C api when patching the default filesystem encoding. (Martin Packman)
modified:
  bzrlib/__init__.py             __init__.py-20050309040759-33e65acf91bbcd5d
=== modified file 'bzrlib/__init__.py'
--- a/bzrlib/__init__.py	2012-01-16 17:24:42 +0000
+++ b/bzrlib/__init__.py	2012-01-23 23:11:45 +0000
@@ -148,13 +148,10 @@
     """
     try:
         import ctypes
-    except ImportError:
-        return
-    pythonapi = getattr(ctypes, "pythonapi", None)
-    if pythonapi is None:
-        # Not CPython ctypes implementation
-        return
-    old_ptr = ctypes.c_void_p.in_dll(pythonapi, "Py_FileSystemDefaultEncoding")
+        old_ptr = ctypes.c_void_p.in_dll(ctypes.pythonapi,
+            "Py_FileSystemDefaultEncoding")
+    except (ImportError, ValueError):
+        return # No ctypes or not CPython implementation, do nothing
     new_ptr = ctypes.cast(ctypes.c_char_p(intern(new_enc)), ctypes.c_void_p)
     old_ptr.value = new_ptr.value
     if sys.getfilesystemencoding() != new_enc:




More information about the bazaar-commits mailing list