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

  • Committer: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2020-07-28 02:47:10 UTC
  • mfrom: (7519.1.1 merge-3.1)
  • Revision ID: breezy.the.bot@gmail.com-20200728024710-a2ylds219f1lsl62
Merge lp:brz/3.1.

Merged from https://code.launchpad.net/~jelmer/brz/merge-3.1/+merge/388173

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
 
from __future__ import absolute_import
18
 
 
19
17
# \subsection{\emph{rio} - simple text metaformat}
20
18
#
21
19
# \emph{r} stands for `restricted', `reproducible', or `rfc822-like'.
36
34
 
37
35
from . import osutils
38
36
from .iterablefile import IterableFile
39
 
from .sixish import (
40
 
    text_type,
41
 
    )
42
37
 
43
38
# XXX: some redundancy is allowing to write stanzas in isolation as well as
44
39
# through a writer object.
139
134
            raise ValueError("invalid tag %r" % (tag,))
140
135
        if isinstance(value, bytes):
141
136
            value = value.decode('ascii')
142
 
        elif isinstance(value, text_type):
 
137
        elif isinstance(value, str):
143
138
            pass
144
139
        else:
145
140
            raise TypeError("invalid type for rio value: %r of type %s"
189
184
        result = []
190
185
        for text_tag, text_value in self.items:
191
186
            tag = text_tag.encode('ascii')
192
 
            value = text_value.encode('utf-8')
 
187
            value = text_value.encode('utf-8', 'surrogateescape')
193
188
            if value == b'':
194
189
                result.append(tag + b': \n')
195
190
            elif b'\n' in value: