/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/cache_utf8.py

  • Committer: Jelmer Vernooij
  • Date: 2018-11-06 02:25:29 UTC
  • mto: This revision was merged to the branch mainline in revision 7150.
  • Revision ID: jelmer@jelmer.uk-20181106022529-qlctdqketvoibpvz
Simplify brz-git, drop imports.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
"""Some functions to enable caching the conversion between unicode to utf8"""
21
21
 
 
22
from __future__ import absolute_import
 
23
 
22
24
import codecs
23
25
 
24
 
 
25
26
_utf8_encode = codecs.utf_8_encode
26
27
_utf8_decode = codecs.utf_8_decode
27
28
def _utf8_decode_with_None(bytestring, _utf8_decode=_utf8_decode):
107
108
    # real Unicode string. Unicode and plain strings of this type will have the
108
109
    # same hash, so we can just use it as the key in _uni_to_utf8, but we need
109
110
    # the return value to be different in _utf8_to_uni
110
 
    ascii_str = _uni_to_utf8.setdefault(ascii_str, ascii_str)
111
 
    _utf8_to_uni.setdefault(ascii_str, unicode(ascii_str))
 
111
    uni_str = ascii_str.decode('ascii')
 
112
    ascii_str = _uni_to_utf8.setdefault(uni_str, ascii_str)
 
113
    _utf8_to_uni.setdefault(ascii_str, uni_str)
112
114
    return ascii_str
113
115
 
114
116