/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-08-10 15:00:17 UTC
  • mfrom: (7490.40.99 work)
  • mto: This revision was merged to the branch mainline in revision 7521.
  • Revision ID: jelmer@jelmer.uk-20200810150017-vs7xnrd1vat4iktg
Merge lp:brz/3.1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
We hope you enjoy this library.
30
30
"""
31
31
 
32
 
from __future__ import absolute_import
33
 
 
34
32
import time
35
33
 
36
34
# Keep track of when breezy was first imported, so that we can give rough
53
51
# Python version 2.0 is (2, 0, 0, 'final', 0)."  Additionally we use a
54
52
# releaselevel of 'dev' for unreleased under-development code.
55
53
 
56
 
version_info = (3, 1, 0, 'final', 0)
 
54
version_info = (3, 2, 0, 'dev', 0)
57
55
 
58
56
 
59
57
def _format_version_tuple(version_info):
129
127
    The use of intern() may defer breakage is but is not enough, the string
130
128
    object should be secure against module reloading and during teardown.
131
129
    """
132
 
    is_py3 = sys.version_info > (3,)
133
130
    try:
134
131
        import ctypes
135
132
        pythonapi = getattr(ctypes, 'pythonapi', None)
136
133
        if pythonapi is not None:
137
134
            old_ptr = ctypes.c_void_p.in_dll(pythonapi,
138
135
                                             "Py_FileSystemDefaultEncoding")
139
 
            if is_py3:
140
 
                has_enc = ctypes.c_int.in_dll(pythonapi,
141
 
                                              "Py_HasFileSystemDefaultEncoding")
142
 
                as_utf8 = ctypes.PYFUNCTYPE(
143
 
                    ctypes.POINTER(ctypes.c_char), ctypes.py_object)(
144
 
                        ("PyUnicode_AsUTF8", pythonapi))
 
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))
145
141
    except (ImportError, ValueError):
146
142
        return  # No ctypes or not CPython implementation, do nothing
147
 
    if is_py3:
148
 
        new_enc = sys.intern(new_enc)
149
 
        enc_ptr = as_utf8(new_enc)
150
 
        has_enc.value = 1
151
 
    else:
152
 
        new_enc = intern(new_enc)
153
 
        enc_ptr = ctypes.c_char_p(new_enc)
 
143
    new_enc = sys.intern(new_enc)
 
144
    enc_ptr = as_utf8(new_enc)
 
145
    has_enc.value = 1
154
146
    old_ptr.value = ctypes.cast(enc_ptr, ctypes.c_void_p).value
155
147
    if sys.getfilesystemencoding() != new_enc:
156
148
        raise RuntimeError("Failed to change the filesystem default encoding")