~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/__init__.py

  • Committer: Patch Queue Manager
  • Date: 2012-01-26 10:07:07 UTC
  • mfrom: (6445.1.1 trunk)
  • Revision ID: pqm@pqm.ubuntu.com-20120126100707-t8z7zent2kjczkp7
(vila) Merge 2.5 into trunk (Vincent Ladeuil)

Show diffs side-by-side

added added

removed removed

Lines of Context:
148
148
    """
149
149
    try:
150
150
        import ctypes
151
 
    except ImportError:
152
 
        return
153
 
    pythonapi = getattr(ctypes, "pythonapi", None)
154
 
    if pythonapi is None:
155
 
        # Not CPython ctypes implementation
156
 
        return
157
 
    old_ptr = ctypes.c_void_p.in_dll(pythonapi, "Py_FileSystemDefaultEncoding")
 
151
        old_ptr = ctypes.c_void_p.in_dll(ctypes.pythonapi,
 
152
            "Py_FileSystemDefaultEncoding")
 
153
    except (ImportError, ValueError):
 
154
        return # No ctypes or not CPython implementation, do nothing
158
155
    new_ptr = ctypes.cast(ctypes.c_char_p(intern(new_enc)), ctypes.c_void_p)
159
156
    old_ptr.value = new_ptr.value
160
157
    if sys.getfilesystemencoding() != new_enc: