~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/__init__.py

  • Committer: Jelmer Vernooij
  • Date: 2012-01-30 14:18:22 UTC
  • mfrom: (6456 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6464.
  • Revision ID: jelmer@samba.org-20120130141822-u4fqwswoyew4a14a
Merge bzr.dev.

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: