bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
6621.10.1
by Martin
Add bzrlib.sixish module to help porting process |
1 |
# Copyright (C) 2017 Bazaar hackers
|
2 |
#
|
|
3 |
# This program is free software; you can redistribute it and/or modify
|
|
4 |
# it under the terms of the GNU General Public License as published by
|
|
5 |
# the Free Software Foundation; either version 2 of the License, or
|
|
6 |
# (at your option) any later version.
|
|
7 |
#
|
|
8 |
# This program is distributed in the hope that it will be useful,
|
|
9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11 |
# GNU General Public License for more details.
|
|
12 |
#
|
|
13 |
# You should have received a copy of the GNU General Public License
|
|
14 |
# along with this program; if not, write to the Free Software
|
|
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
16 |
||
17 |
"""
|
|
18 |
Module to aid writing a Python dialect compatible with 2.7 and 3.4+.
|
|
19 |
||
20 |
Initially pretty much just a subset of six while things get worked out.
|
|
21 |
"""
|
|
22 |
||
23 |
from __future__ import absolute_import |
|
24 |
||
25 |
from six import ( |
|
26 |
binary_type, |
|
6963.1.1
by Jelmer Vernooij
Fix a bunch of tests on python3. |
27 |
get_unbound_function, |
6803.2.2
by Martin
Make groupcompress Python 3 compatible |
28 |
indexbytes, |
29 |
int2byte, |
|
6621.10.1
by Martin
Add bzrlib.sixish module to help porting process |
30 |
PY3, |
31 |
reraise, |
|
32 |
string_types, |
|
33 |
text_type, |
|
7031.1.1
by Jelmer Vernooij
Fix breezy.tests.test_diff. |
34 |
unichr, |
6621.10.1
by Martin
Add bzrlib.sixish module to help porting process |
35 |
viewitems, |
6651.4.1
by Martin
Rewrite of the plugin module for Python 3 compat and general sanity |
36 |
viewkeys, |
6621.10.1
by Martin
Add bzrlib.sixish module to help porting process |
37 |
viewvalues, |
38 |
)
|
|
39 |
||
40 |
||
41 |
# The io module exists in Python 2.7 but lacks optimisation. Most uses are not
|
|
42 |
# performance critical, but want to measure before switching from cStringIO.
|
|
43 |
if PY3: |
|
6621.22.2
by Martin
Use BytesIO or StringIO from bzrlib.sixish |
44 |
import io as _io |
45 |
BytesIO = _io.BytesIO |
|
46 |
StringIO = _io.StringIO |
|
6651.2.2
by Martin
Apply 2to3 xrange fix and fix up with sixish range |
47 |
from builtins import range, map, zip |
6621.10.1
by Martin
Add bzrlib.sixish module to help porting process |
48 |
else: |
49 |
from cStringIO import StringIO as BytesIO |
|
50 |
from StringIO import StringIO |
|
6631.2.3
by Martin
Fix per_versionedfile test failures and rethink future_builtins |
51 |
from future_builtins import zip, map |
6651.2.2
by Martin
Apply 2to3 xrange fix and fix up with sixish range |
52 |
range = xrange |
6684.1.3
by Martin
Changes across many modules working towards Python 3 support |
53 |
|
54 |
||
55 |
# GZ 2017-06-10: Work out if interning bits of inventory is behaviour we want
|
|
56 |
# to retain outside of StaticTuple, if so need to implement for Python 3.
|
|
57 |
if PY3: |
|
58 |
def bytesintern(b): |
|
59 |
"""Dummy intern() function.""" |
|
60 |
return b |
|
61 |
else: |
|
62 |
bytesintern = intern |