/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/__init__.py

  • Committer: Jelmer Vernooij
  • Date: 2020-06-19 21:26:53 UTC
  • mfrom: (7490.40.19 work)
  • mto: This revision was merged to the branch mainline in revision 7516.
  • Revision ID: jelmer@jelmer.uk-20200619212653-7j6rgywzczhc8cmj
Merge lp:brz/3.1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
129
129
    """
130
130
    try:
131
131
        import ctypes
132
 
        old_ptr = ctypes.c_void_p.in_dll(ctypes.pythonapi,
133
 
                                         "Py_FileSystemDefaultEncoding")
134
 
        has_enc = ctypes.c_int.in_dll(ctypes.pythonapi,
135
 
                                      "Py_HasFileSystemDefaultEncoding")
136
 
        as_utf8 = ctypes.PYFUNCTYPE(
137
 
            ctypes.POINTER(ctypes.c_char), ctypes.py_object)(
138
 
                ("PyUnicode_AsUTF8", ctypes.pythonapi))
 
132
        pythonapi = getattr(ctypes, 'pythonapi', None)
 
133
        if pythonapi is not None:
 
134
            old_ptr = ctypes.c_void_p.in_dll(pythonapi,
 
135
                                             "Py_FileSystemDefaultEncoding")
 
136
            has_enc = ctypes.c_int.in_dll(pythonapi,
 
137
                                          "Py_HasFileSystemDefaultEncoding")
 
138
            as_utf8 = ctypes.PYFUNCTYPE(
 
139
                ctypes.POINTER(ctypes.c_char), ctypes.py_object)(
 
140
                    ("PyUnicode_AsUTF8", pythonapi))
139
141
    except (ImportError, ValueError):
140
142
        return  # No ctypes or not CPython implementation, do nothing
141
143
    new_enc = sys.intern(new_enc)