~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/__init__.py

  • Committer: Jelmer Vernooij
  • Date: 2012-01-28 00:41:30 UTC
  • mfrom: (6437.3.27 2.5)
  • mto: (6437.3.28 2.5)
  • mto: This revision was merged to the branch mainline in revision 6451.
  • Revision ID: jelmer@samba.org-20120128004130-tegh5t5229lr1srg
mergeĀ lp:bzr/2.5.

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: