/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: 2018-11-16 19:47:19 UTC
  • mfrom: (7178 work)
  • mto: This revision was merged to the branch mainline in revision 7179.
  • Revision ID: jelmer@jelmer.uk-20181116194719-m5ut2wfuze5x9s1p
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
53
53
 
54
54
version_info = (3, 0, 0, 'alpha', 1)
55
55
 
 
56
 
56
57
def _format_version_tuple(version_info):
57
58
    """Turn a version number 2, 3 or 5-tuple into a short string.
58
59
 
111
112
    return main_version + sub_string
112
113
 
113
114
 
114
 
# lazy_regex import must be done after _format_version_tuple definition
115
 
# to avoid "no attribute '_format_version_tuple'" error when using
116
 
# deprecated_function in the lazy_regex module.
117
 
if getattr(sys, '_brz_lazy_regex', False):
118
 
    # The 'brz' executable sets _brz_lazy_regex.  We install the lazy regex
119
 
    # hack as soon as possible so that as much of the standard library can
120
 
    # benefit, including the 'string' module.
121
 
    del sys._brz_lazy_regex
122
 
    import breezy.lazy_regex
123
 
    breezy.lazy_regex.install_lazy_compile()
124
 
 
125
 
 
126
115
__version__ = _format_version_tuple(version_info)
127
116
version_string = __version__
128
117
 
129
118
 
130
119
def _patch_filesystem_default_encoding(new_enc):
131
120
    """Change the Python process global encoding for filesystem names
132
 
    
 
121
 
133
122
    The effect is to change how open() and other builtin functions handle
134
123
    unicode filenames on posix systems. This should only be done near startup.
135
124
 
142
131
    try:
143
132
        import ctypes
144
133
        old_ptr = ctypes.c_void_p.in_dll(ctypes.pythonapi,
145
 
            "Py_FileSystemDefaultEncoding")
 
134
                                         "Py_FileSystemDefaultEncoding")
146
135
        if is_py3:
147
136
            has_enc = ctypes.c_int.in_dll(ctypes.pythonapi,
148
 
                "Py_HasFileSystemDefaultEncoding")
 
137
                                          "Py_HasFileSystemDefaultEncoding")
149
138
            as_utf8 = ctypes.PYFUNCTYPE(
150
139
                ctypes.POINTER(ctypes.c_char), ctypes.py_object)(
151
140
                    ("PyUnicode_AsUTF8", ctypes.pythonapi))
152
141
    except (ImportError, ValueError):
153
 
        return # No ctypes or not CPython implementation, do nothing
 
142
        return  # No ctypes or not CPython implementation, do nothing
154
143
    if is_py3:
155
144
        new_enc = sys.intern(new_enc)
156
145
        enc_ptr = as_utf8(new_enc)