Merge lp:~jelmer/brz/no-safe-unicode into lp:brz/3.3

Proposed by Jelmer Vernooij
Status: Needs review
Proposed branch: lp:~jelmer/brz/no-safe-unicode
Merge into: lp:brz/3.3
Diff against target: 776 lines (+102/-160) (has conflicts)
26 files modified
breezy/_walkdirs_win32.pyx (+2/-5)
breezy/bzr/tests/per_versionedfile.py (+4/-4)
breezy/bzr/versionedfile.py (+4/-4)
breezy/bzr/workingtree_3.py (+1/-2)
breezy/bzr/workingtree_4.py (+3/-4)
breezy/config.py (+1/-1)
breezy/email_message.py (+3/-6)
breezy/errors.py (+0/-38)
breezy/git/branch.py (+2/-1)
breezy/git/fetch.py (+1/-1)
breezy/git/refs.py (+7/-7)
breezy/git/roundtrip.py (+1/-1)
breezy/git/tests/test_remote.py (+1/-1)
breezy/git/tree.py (+2/-3)
breezy/gpg.py (+1/-1)
breezy/osutils.py (+30/-2)
breezy/plugins/launchpad/lp_api.py (+1/-1)
breezy/plugins/po_merge/tests/test_po_merge.py (+16/-16)
breezy/plugins/weave_fmt/repository.py (+1/-1)
breezy/smtp_connection.py (+1/-8)
breezy/tests/blackbox/test_export.py (+7/-0)
breezy/tests/test_email_message.py (+2/-3)
breezy/tests/test_osutils.py (+2/-42)
breezy/tests/test_smtp_connection.py (+7/-5)
breezy/utextwrap.py (+2/-2)
breezy/workingtree.py (+0/-1)
Text conflict in breezy/osutils.py
Text conflict in breezy/tests/blackbox/test_export.py
To merge this branch: bzr merge lp:~jelmer/brz/no-safe-unicode
Reviewer Review Type Date Requested Status
Jelmer Vernooij Approve
Review via email: mp+432229@code.launchpad.net

This proposal supersedes a proposal from 2021-12-25.

Commit message

Drop safe_unicode and safe_utf8.

Description of the change

Drop safe_unicode and safe_utf8.

To post a comment you must log in.
Revision history for this message
Jelmer Vernooij (jelmer) : Posted in a previous version of this proposal
review: Approve
Revision history for this message
The Breezy Bot (the-breezy-bot) wrote : Posted in a previous version of this proposal
Revision history for this message
The Breezy Bot (the-breezy-bot) wrote : Posted in a previous version of this proposal
Revision history for this message
The Breezy Bot (the-breezy-bot) wrote : Posted in a previous version of this proposal
Revision history for this message
Jelmer Vernooij (jelmer) :
review: Approve

Unmerged revisions

7569. By Jelmer Vernooij

Avoid safe_* in cython.

7568. By Jelmer Vernooij

Drop safe_unicode.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'breezy/_walkdirs_win32.pyx'
2--- breezy/_walkdirs_win32.pyx 2020-06-08 19:42:53 +0000
3+++ breezy/_walkdirs_win32.pyx 2022-10-27 08:09:03 +0000
4@@ -187,11 +187,8 @@
5
6 def top_prefix_to_starting_dir(self, top, prefix=""):
7 """See DirReader.top_prefix_to_starting_dir."""
8- global osutils
9- if osutils is None:
10- from . import osutils
11- return (osutils.safe_utf8(prefix), None, None, None,
12- osutils.safe_unicode(top))
13+ return (prefix.encode('utf-8'), None, None, None,
14+ top.decnde('utf-8'))
15
16 cdef object _get_kind(self, WIN32_FIND_DATAW *data):
17 if data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY:
18
19=== modified file 'breezy/bzr/tests/per_versionedfile.py'
20--- breezy/bzr/tests/per_versionedfile.py 2022-08-22 18:19:46 +0000
21+++ breezy/bzr/tests/per_versionedfile.py 2022-10-27 08:09:03 +0000
22@@ -249,10 +249,10 @@
23 # unicode content is not permitted in versioned files.
24 # versioned files version sequences of bytes only.
25 vf = self.get_file()
26- self.assertRaises(errors.BzrBadParameterUnicode,
27+ self.assertRaises(TypeError,
28 vf.add_lines, b'a', [], [b'a\n', u'b\n', b'c\n'])
29 self.assertRaises(
30- (errors.BzrBadParameterUnicode, NotImplementedError),
31+ (TypeError, NotImplementedError),
32 vf.add_lines_with_ghosts, b'a', [], [b'a\n', u'b\n', b'c\n'])
33
34 def test_add_follows_left_matching_blocks(self):
35@@ -275,10 +275,10 @@
36 def test_inline_newline_throws(self):
37 # \r characters are not permitted in lines being added
38 vf = self.get_file()
39- self.assertRaises(errors.BzrBadParameterContainsNewline,
40+ self.assertRaises(ValueError,
41 vf.add_lines, b'a', [], [b'a\n\n'])
42 self.assertRaises(
43- (errors.BzrBadParameterContainsNewline, NotImplementedError),
44+ (ValueError, NotImplementedError),
45 vf.add_lines_with_ghosts, b'a', [], [b'a\n\n'])
46 # but inline CR's are allowed
47 vf.add_lines(b'a', [], [b'a\r\n'])
48
49=== modified file 'breezy/bzr/versionedfile.py'
50--- breezy/bzr/versionedfile.py 2022-09-08 14:15:34 +0000
51+++ breezy/bzr/versionedfile.py 2022-10-27 08:09:03 +0000
52@@ -556,13 +556,13 @@
53 """Check that lines being added to a versioned file are not unicode."""
54 for line in lines:
55 if not isinstance(line, bytes):
56- raise errors.BzrBadParameterUnicode("lines")
57+ raise TypeError(lines)
58
59 def _check_lines_are_lines(self, lines):
60 """Check that the lines really are full lines without inline EOL."""
61 for line in lines:
62 if b'\n' in line[:-1]:
63- raise errors.BzrBadParameterContainsNewline("lines")
64+ raise ValueError(lines)
65
66 def get_format_signature(self):
67 """Get a text description of the data encoding in this file.
68@@ -1177,13 +1177,13 @@
69 """Check that lines being added to a versioned file are not unicode."""
70 for line in lines:
71 if line.__class__ is not bytes:
72- raise errors.BzrBadParameterUnicode("lines")
73+ raise TypeError(lines)
74
75 def _check_lines_are_lines(self, lines):
76 """Check that the lines really are full lines without inline EOL."""
77 for line in lines:
78 if b'\n' in line[:-1]:
79- raise errors.BzrBadParameterContainsNewline("lines")
80+ raise ValueError(lines)
81
82 def get_known_graph_ancestry(self, keys):
83 """Get a KnownGraph instance with the ancestry of keys."""
84
85=== modified file 'breezy/bzr/workingtree_3.py'
86--- breezy/bzr/workingtree_3.py 2022-08-22 18:19:46 +0000
87+++ breezy/bzr/workingtree_3.py 2022-10-27 08:09:03 +0000
88@@ -80,8 +80,7 @@
89 # warning might be sufficient to let the user know what
90 # is going on.
91 trace.mutter('Could not write hashcache for %s\nError: %s',
92- self._hashcache.cache_file_name(),
93- osutils.safe_unicode(e.args[1]))
94+ self._hashcache.cache_file_name(), e.args[1])
95
96 def get_file_sha1(self, path, stat_value=None):
97 with self.lock_read():
98
99=== modified file 'breezy/bzr/workingtree_4.py'
100--- breezy/bzr/workingtree_4.py 2022-08-22 18:19:46 +0000
101+++ breezy/bzr/workingtree_4.py 2022-10-27 08:09:03 +0000
102@@ -71,7 +71,6 @@
103 isdir,
104 pathjoin,
105 realpath,
106- safe_unicode,
107 )
108 from ..transport import get_transport_from_path, NoSuchFile
109 from ..transport.local import LocalTransport
110@@ -105,7 +104,7 @@
111 """
112 self._format = _format
113 self.controldir = _controldir
114- basedir = safe_unicode(basedir)
115+ basedir = basedir.decode('utf-8') if isinstance(basedir, bytes) else basedir
116 trace.mutter("opening working tree %r", basedir)
117 self._branch = branch
118 self.basedir = realpath(basedir)
119@@ -1395,13 +1394,13 @@
120 def sha1(self, abspath):
121 """See dirstate.SHA1Provider.sha1()."""
122 filters = self.tree._content_filter_stack(
123- self.tree.relpath(osutils.safe_unicode(abspath)))
124+ self.tree.relpath(abspath))
125 return _mod_filters.internal_size_sha_file_byname(abspath, filters)[1]
126
127 def stat_and_sha1(self, abspath):
128 """See dirstate.SHA1Provider.stat_and_sha1()."""
129 filters = self.tree._content_filter_stack(
130- self.tree.relpath(osutils.safe_unicode(abspath)))
131+ self.tree.relpath(abspath))
132 with open(abspath, 'rb', 65000) as file_obj:
133 statvalue = os.fstat(file_obj.fileno())
134 if filters:
135
136=== modified file 'breezy/config.py'
137--- breezy/config.py 2022-09-01 19:17:39 +0000
138+++ breezy/config.py 2022-10-27 08:09:03 +0000
139@@ -968,7 +968,7 @@
140
141 def __init__(self, file_name):
142 super(LockableConfig, self).__init__(file_name=file_name)
143- self.dir = osutils.dirname(osutils.safe_unicode(self.file_name))
144+ self.dir = osutils.dirname(self.file_name)
145 # FIXME: It doesn't matter that we don't provide possible_transports
146 # below since this is currently used only for local config files ;
147 # local transports are not shared. But if/when we start using
148
149=== modified file 'breezy/email_message.py'
150--- breezy/email_message.py 2020-02-18 01:57:45 +0000
151+++ breezy/email_message.py 2022-10-27 08:09:03 +0000
152@@ -22,8 +22,6 @@
153 from email.mime.text import MIMEText
154 from email.utils import formataddr, parseaddr
155 from . import __version__ as _breezy_version
156-from .errors import BzrBadParameterNotUnicode
157-from .osutils import safe_unicode
158 from .smtp_connection import SMTPConnection
159
160
161@@ -66,7 +64,7 @@
162
163 self._headers['To'] = ', '.join(to_addresses)
164 self._headers['From'] = self.address_to_encoded_header(from_address)
165- self._headers['Subject'] = Header(safe_unicode(subject))
166+ self._headers['Subject'] = Header(subject)
167 self._headers['User-Agent'] = 'Bazaar (%s)' % _breezy_version
168
169 def add_inline_attachment(self, body, filename=None, mime_subtype='plain'):
170@@ -167,15 +165,14 @@
171 :return: A possibly RFC2047-encoded string.
172 """
173 if not isinstance(address, str):
174- raise BzrBadParameterNotUnicode(address)
175+ raise TypeError(address)
176 # Can't call Header over all the address, because that encodes both the
177 # name and the email address, which is not permitted by RFCs.
178 user, email = parseaddr(address)
179 if not user:
180 return email
181 else:
182- return formataddr((str(Header(safe_unicode(user))),
183- email))
184+ return formataddr((str(Header(user)), email))
185
186 @staticmethod
187 def string_with_encoding(string_):
188
189=== modified file 'breezy/errors.py'
190--- breezy/errors.py 2022-08-22 18:19:46 +0000
191+++ breezy/errors.py 2022-10-27 08:09:03 +0000
192@@ -1378,23 +1378,6 @@
193 self.prefix = prefix
194
195
196-class BzrBadParameter(InternalBzrError):
197-
198- _fmt = "Bad parameter: %(param)r"
199-
200- # This exception should never be thrown, but it is a base class for all
201- # parameter-to-function errors.
202-
203- def __init__(self, param):
204- BzrError.__init__(self)
205- self.param = param
206-
207-
208-class BzrBadParameterNotUnicode(BzrBadParameter):
209-
210- _fmt = "Parameter %(param)s is neither unicode nor utf8."
211-
212-
213 class BzrMoveFailedError(BzrError):
214
215 _fmt = ("Could not move %(from_path)s%(operator)s %(to_path)s"
216@@ -1440,27 +1423,6 @@
217 BzrMoveFailedError.__init__(self, from_path, to_path, extra)
218
219
220-class BzrBadParameterNotString(BzrBadParameter):
221-
222- _fmt = "Parameter %(param)s is not a string or unicode string."
223-
224-
225-class BzrBadParameterMissing(BzrBadParameter):
226-
227- _fmt = "Parameter %(param)s is required but not present."
228-
229-
230-class BzrBadParameterUnicode(BzrBadParameter):
231-
232- _fmt = ("Parameter %(param)s is unicode but"
233- " only byte-strings are permitted.")
234-
235-
236-class BzrBadParameterContainsNewline(BzrBadParameter):
237-
238- _fmt = "Parameter %(param)s contains a newline."
239-
240-
241 class ParamikoNotPresent(DependencyNotPresent):
242
243 _fmt = "Unable to import paramiko (required for sftp support): %(error)s"
244
245=== modified file 'breezy/git/branch.py'
246--- breezy/git/branch.py 2022-08-28 18:54:11 +0000
247+++ breezy/git/branch.py 2022-10-27 08:09:03 +0000
248@@ -1211,8 +1211,9 @@
249 raise errors.DivergedBranches(self.source, self.target)
250 refs = {self.target.ref: new_ref}
251 result.new_revid = stop_revision
252- for name, sha in (
253+ for utf8_name, sha in (
254 self.source.repository._git.refs.as_dict(b"refs/tags").items()):
255+ name = utf8_name.decode('utf-8')
256 if tag_selector and not tag_selector(name):
257 continue
258 if sha not in self.source.repository._git:
259
260=== modified file 'breezy/git/fetch.py'
261--- breezy/git/fetch.py 2022-08-22 18:19:46 +0000
262+++ breezy/git/fetch.py 2022-10-27 08:09:03 +0000
263@@ -259,7 +259,7 @@
264 # If nothing has changed since the base revision, we're done
265 return [], {}
266 invdelta = []
267- file_id = lookup_file_id(osutils.safe_unicode(path))
268+ file_id = lookup_file_id(path)
269 ie = InventoryDirectory(file_id, decode_git_path(name), parent_id)
270 tree = lookup_object(hexsha)
271 if base_hexsha is None:
272
273=== modified file 'breezy/git/refs.py'
274--- breezy/git/refs.py 2022-07-15 13:59:24 +0000
275+++ breezy/git/refs.py 2022-10-27 08:09:03 +0000
276@@ -60,7 +60,7 @@
277 return ret
278
279
280-def branch_name_to_ref(name):
281+def branch_name_to_ref(name: str) -> bytes:
282 """Map a branch name to a ref.
283
284 :param name: Branch name
285@@ -69,18 +69,18 @@
286 if name == "":
287 return b"HEAD"
288 if not name.startswith("refs/"):
289- return LOCAL_BRANCH_PREFIX + osutils.safe_utf8(name)
290+ return LOCAL_BRANCH_PREFIX + name.encode('utf-8')
291 else:
292- return osutils.safe_utf8(name)
293-
294-
295-def tag_name_to_ref(name):
296+ return name.encode('utf-8')
297+
298+
299+def tag_name_to_ref(name: str) -> bytes:
300 """Map a tag name to a ref.
301
302 :param name: Tag name
303 :return: ref string
304 """
305- return LOCAL_TAG_PREFIX + osutils.safe_utf8(name)
306+ return LOCAL_TAG_PREFIX + name.encode('utf-8')
307
308
309 def ref_to_branch_name(ref):
310
311=== modified file 'breezy/git/roundtrip.py'
312--- breezy/git/roundtrip.py 2020-02-18 01:57:45 +0000
313+++ breezy/git/roundtrip.py 2022-10-27 08:09:03 +0000
314@@ -117,7 +117,7 @@
315 b" ".join(metadata.explicit_parent_ids))
316 for key in sorted(metadata.properties.keys()):
317 for l in metadata.properties[key].split(b"\n"):
318- lines.append(b"property-%s: %s\n" % (key, osutils.safe_utf8(l)))
319+ lines.append(b"property-%s: %s\n" % (key, l))
320 if b"testament3-sha1" in metadata.verifiers:
321 lines.append(b"testament3-sha1: %s\n" %
322 metadata.verifiers[b"testament3-sha1"])
323
324=== modified file 'breezy/git/tests/test_remote.py'
325--- breezy/git/tests/test_remote.py 2022-09-14 13:52:36 +0000
326+++ breezy/git/tests/test_remote.py 2022-10-27 08:09:03 +0000
327@@ -775,7 +775,7 @@
328
329 remote = ControlDir.open(self.remote_url)
330 remote.open_branch().tags.set_tag(
331- b'blah', default_mapping.revision_id_foreign_to_bzr(c1))
332+ 'blah', default_mapping.revision_id_foreign_to_bzr(c1))
333 self.assertEqual(
334 self.remote_real.get_refs(),
335 {b'refs/heads/master': self.remote_real.head(),
336
337=== modified file 'breezy/git/tree.py'
338--- breezy/git/tree.py 2022-10-02 16:57:16 +0000
339+++ breezy/git/tree.py 2022-10-27 08:09:03 +0000
340@@ -412,7 +412,7 @@
341 return None
342 if not self.is_versioned(path):
343 return None
344- return self.mapping.generate_file_id(osutils.safe_unicode(path))
345+ return self.mapping.generate_file_id(path)
346
347 def all_versioned_paths(self):
348 ret = {u''}
349@@ -1172,8 +1172,7 @@
350 with self.lock_read():
351 path = path.rstrip('/')
352 if self.is_versioned(path.rstrip('/')):
353- return self.mapping.generate_file_id(
354- osutils.safe_unicode(path))
355+ return self.mapping.generate_file_id(path)
356 return None
357
358 def _set_root_id(self, file_id):
359
360=== modified file 'breezy/gpg.py'
361--- breezy/gpg.py 2022-05-15 14:17:32 +0000
362+++ breezy/gpg.py 2022-10-27 08:09:03 +0000
363@@ -239,7 +239,7 @@
364 'Set create_signatures=no to disable creating signatures.')
365
366 if isinstance(content, str):
367- raise errors.BzrBadParameterUnicode('content')
368+ raise TypeError(content)
369
370 plain_text = gpg.Data(content)
371 try:
372
373=== modified file 'breezy/osutils.py'
374--- breezy/osutils.py 2022-09-22 22:55:28 +0000
375+++ breezy/osutils.py 2022-10-27 08:09:03 +0000
376@@ -1302,6 +1302,7 @@
377 return [canonical_relpath(base, p) for p in paths]
378
379
380+<<<<<<< TREE
381 def safe_unicode(unicode_or_utf8_string):
382 """Coerce unicode_or_utf8_string into unicode.
383
384@@ -1336,6 +1337,23 @@
385 return unicode_or_utf8_string.encode('utf-8')
386
387
388+=======
389+def decode_filename(filename):
390+ """Decode the filename using the filesystem encoding
391+
392+ If it is unicode, it is returned.
393+ Otherwise it is decoded from the the filesystem's encoding. If decoding
394+ fails, a errors.BadFilenameEncoding exception is raised.
395+ """
396+ if isinstance(filename, str):
397+ return filename
398+ try:
399+ return filename.decode(_fs_enc)
400+ except UnicodeDecodeError:
401+ raise errors.BadFilenameEncoding(filename, _fs_enc)
402+
403+
404+>>>>>>> MERGE-SOURCE
405 _platform_normalizes_filenames = False
406 if sys.platform == 'darwin':
407 _platform_normalizes_filenames = True
408@@ -1709,7 +1727,7 @@
409 # potentially confusing output. We should make this more robust - but
410 # not at a speed cost. RBC 20060731
411 _directory = _directory_kind
412- pending = [(safe_unicode(prefix), "", _directory, None, safe_unicode(top))]
413+ pending = [(prefix, "", _directory, None, top)]
414 while pending:
415 # 0 - relpath, 1- basename, 2- kind, 3- stat, 4-toppath
416 relroot, _, _, _, top = pending.pop()
417@@ -1827,7 +1845,8 @@
418
419 def top_prefix_to_starting_dir(self, top, prefix=""):
420 """See DirReader.top_prefix_to_starting_dir."""
421- return (safe_utf8(prefix), None, None, None, safe_unicode(top))
422+ return (prefix.encode('utf-8')
423+ if isinstance(prefix, str) else prefix, None, None, None, top)
424
425 def read_dir(self, prefix, top):
426 """Read a single directory from a non-utf8 file system.
427@@ -1852,8 +1871,17 @@
428
429 dirblock = []
430 append = dirblock.append
431+<<<<<<< TREE
432 for entry in scandir(safe_utf8(top)):
433 name = os.fsdecode(entry.name)
434+=======
435+ for entry in scandir(_fs_encode(top)):
436+ try:
437+ name = _fs_decode(entry.name)
438+ except UnicodeDecodeError:
439+ raise errors.BadFilenameEncoding(
440+ relprefix + entry.name, _fs_enc)
441+>>>>>>> MERGE-SOURCE
442 abspath = top_slash + name
443 name_utf8 = _utf8_encode(name, 'surrogateescape')[0]
444 statvalue = entry.stat(follow_symlinks=False)
445
446=== modified file 'breezy/plugins/launchpad/lp_api.py'
447--- breezy/plugins/launchpad/lp_api.py 2022-09-07 01:35:37 +0000
448+++ breezy/plugins/launchpad/lp_api.py 2022-10-27 08:09:03 +0000
449@@ -314,7 +314,7 @@
450 self.lp.bzr_identity)
451 return
452 graph = self.bzr.repository.get_graph()
453- if not graph.is_ancestor(osutils.safe_utf8(self.lp.last_scanned_id),
454+ if not graph.is_ancestor(self.lp.last_scanned_id.encode('utf-8'),
455 self.bzr.last_revision()):
456 raise errors.DivergedBranches(self.bzr, self.push_bzr)
457 trace.note(gettext('Pushing to %s') % self.lp.bzr_identity)
458
459=== modified file 'breezy/plugins/po_merge/tests/test_po_merge.py'
460--- breezy/plugins/po_merge/tests/test_po_merge.py 2018-11-11 04:08:32 +0000
461+++ breezy/plugins/po_merge/tests/test_po_merge.py 2022-10-27 08:09:03 +0000
462@@ -152,7 +152,7 @@
463 # beginning of the file.
464
465 _Adduser = dict(
466- base_pot=osutils.safe_utf8(r"""# SOME DESCRIPTIVE TITLE.
467+ base_pot=br"""# SOME DESCRIPTIVE TITLE.
468 # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
469 # This file is distributed under the same license as the PACKAGE package.
470 # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
471@@ -179,8 +179,8 @@
472 msgid "Warning: The home dir you specified already exists.\n"
473 msgstr ""
474
475-"""),
476- this_pot=osutils.safe_utf8(r"""# SOME DESCRIPTIVE TITLE.
477+""",
478+ this_pot=br"""# SOME DESCRIPTIVE TITLE.
479 # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
480 # This file is distributed under the same license as the PACKAGE package.
481 # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
482@@ -214,8 +214,8 @@
483 msgid "Warning: The home dir %s you specified can't be accessed: %s\n"
484 msgstr ""
485
486-"""),
487- other_pot=osutils.safe_utf8(r"""# SOME DESCRIPTIVE TITLE.
488+""",
489+ other_pot=br"""# SOME DESCRIPTIVE TITLE.
490 # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
491 # This file is distributed under the same license as the PACKAGE package.
492 # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
493@@ -249,8 +249,8 @@
494 msgid "Warning: The home dir %s you specified can't be accessed: %s\n"
495 msgstr ""
496
497-"""),
498- resolved_pot=osutils.safe_utf8(r"""# SOME DESCRIPTIVE TITLE.
499+""",
500+ resolved_pot=br"""# SOME DESCRIPTIVE TITLE.
501 # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
502 # This file is distributed under the same license as the PACKAGE package.
503 # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
504@@ -284,8 +284,8 @@
505 msgid "Warning: The home dir %s you specified can't be accessed: %s\n"
506 msgstr ""
507
508-"""),
509- base_po=osutils.safe_utf8(r"""# adduser's manpages translation to French
510+""",
511+ base_po=br"""# adduser's manpages translation to French
512 # Copyright (C) 2004 Software in the Public Interest
513 # This file is distributed under the same license as the adduser package
514 #
515@@ -320,8 +320,8 @@
516 msgstr ""
517 "Attention ! Le répertoire personnel que vous avez indiqué existe déjà.\n"
518
519-"""),
520- this_po=osutils.safe_utf8(r"""# adduser's manpages translation to French
521+""",
522+ this_po=br"""# adduser's manpages translation to French
523 # Copyright (C) 2004 Software in the Public Interest
524 # This file is distributed under the same license as the adduser package
525 #
526@@ -363,8 +363,8 @@
527 msgstr ""
528 "Attention ! Le répertoire personnel que vous avez indiqué existe déjà.\n"
529
530-"""),
531- other_po=osutils.safe_utf8(r"""# adduser's manpages translation to French
532+""",
533+ other_po=br"""# adduser's manpages translation to French
534 # Copyright (C) 2004 Software in the Public Interest
535 # This file is distributed under the same license as the adduser package
536 #
537@@ -406,8 +406,8 @@
538 "Attention ! Impossible d'accéder au répertoire personnel que vous avez "
539 "indiqué (%s) : %s.\n"
540
541-"""),
542- resolved_po=osutils.safe_utf8(r"""# adduser's manpages translation to French
543+""",
544+ resolved_po=br"""# adduser's manpages translation to French
545 # Copyright (C) 2004 Software in the Public Interest
546 # This file is distributed under the same license as the adduser package
547 #
548@@ -449,5 +449,5 @@
549 "Attention ! Impossible d'accéder au répertoire personnel que vous avez "
550 "indiqué (%s) : %s.\n"
551
552-"""),
553+""",
554 )
555
556=== modified file 'breezy/plugins/weave_fmt/repository.py'
557--- breezy/plugins/weave_fmt/repository.py 2022-08-22 18:19:46 +0000
558+++ breezy/plugins/weave_fmt/repository.py 2022-10-27 08:09:03 +0000
559@@ -88,7 +88,7 @@
560 file_or_path = '/'.join(file_or_path)
561 if file_or_path == '':
562 return u''
563- return urlutils.escape(osutils.safe_unicode(file_or_path))
564+ return urlutils.escape(file_or_path)
565
566 def __init__(self, _format, a_controldir):
567 # we reuse one control files instance.
568
569=== modified file 'breezy/smtp_connection.py'
570--- breezy/smtp_connection.py 2021-11-15 16:36:47 +0000
571+++ breezy/smtp_connection.py 2022-10-27 08:09:03 +0000
572@@ -157,14 +157,7 @@
573 self._smtp_password = auth.get_password(
574 'smtp', self._smtp_server, self._smtp_username)
575
576- # smtplib requires that the username and password be byte
577- # strings. The CRAM-MD5 spec doesn't give any guidance on
578- # encodings, but the SASL PLAIN spec says UTF-8, so that's
579- # what we'll use.
580- username = osutils.safe_utf8(self._smtp_username)
581- password = osutils.safe_utf8(self._smtp_password)
582-
583- self._connection.login(username, password)
584+ self._connection.login(self._smtp_username, self._smtp_password)
585
586 @staticmethod
587 def get_message_addresses(message):
588
589=== modified file 'breezy/tests/blackbox/test_export.py'
590--- breezy/tests/blackbox/test_export.py 2022-05-03 20:36:36 +0000
591+++ breezy/tests/blackbox/test_export.py 2022-10-27 08:09:03 +0000
592@@ -111,10 +111,17 @@
593 tree.commit('first')
594
595 self.run_bzr('export test.tar -d tar')
596+<<<<<<< TREE
597 with tarfile.open('test.tar') as ball:
598 # all paths are prefixed with the base name of the tarball
599 self.assertEqual([u'test/' + fname],
600 [osutils.safe_unicode(n) for n in ball.getnames()])
601+=======
602+ ball = tarfile.open('test.tar')
603+ # all paths are prefixed with the base name of the tarball
604+ self.assertEqual([u'test/' + fname],
605+ [n for n in ball.getnames()])
606+>>>>>>> MERGE-SOURCE
607
608 def test_tar_export_unicode_basedir(self):
609 """Test for bug #413406"""
610
611=== modified file 'breezy/tests/test_email_message.py'
612--- breezy/tests/test_email_message.py 2020-02-07 02:14:30 +0000
613+++ breezy/tests/test_email_message.py 2022-10-27 08:09:03 +0000
614@@ -19,7 +19,6 @@
615
616 from .. import __version__ as _breezy_version
617 from ..email_message import EmailMessage
618-from ..errors import BzrBadParameterNotUnicode
619 from ..smtp_connection import SMTPConnection
620 from .. import tests
621
622@@ -133,7 +132,7 @@
623 for i in range(3): # from_address, to_address, subject
624 x = [b'"J. Random Developer" <jrandom@example.com>'] * 3
625 x[i] = b'Pepe P\xe9rez <pperez@ejemplo.com>'
626- self.assertRaises(BzrBadParameterNotUnicode, EmailMessage, *x)
627+ self.assertRaises(TypeError, EmailMessage, *x)
628
629 def test_multiple_destinations(self):
630 to_addresses = ['to1@to.com', 'to2@to.com', 'to3@to.com']
631@@ -183,7 +182,7 @@
632 self.assertEqual(address, decode(encoded))
633
634 address = b'Pepe P\xe9rez <pperez@ejemplo.com>' # ISO-8859-1 not ok
635- self.assertRaises(BzrBadParameterNotUnicode,
636+ self.assertRaises(TypeError,
637 EmailMessage.address_to_encoded_header, address)
638
639 def test_string_with_encoding(self):
640
641=== modified file 'breezy/tests/test_osutils.py'
642--- breezy/tests/test_osutils.py 2022-09-23 07:44:01 +0000
643+++ breezy/tests/test_osutils.py 2022-10-27 08:09:03 +0000
644@@ -775,46 +775,6 @@
645 osutils.relpath, 'C:/', 'H:/path')
646
647
648-class TestSafeUnicode(tests.TestCase):
649-
650- def test_from_ascii_string(self):
651- self.assertEqual(u'foobar', osutils.safe_unicode(b'foobar'))
652-
653- def test_from_unicode_string_ascii_contents(self):
654- self.assertEqual(u'bargam', osutils.safe_unicode(u'bargam'))
655-
656- def test_from_unicode_string_unicode_contents(self):
657- self.assertEqual(u'bargam\xae', osutils.safe_unicode(u'bargam\xae'))
658-
659- def test_from_utf8_string(self):
660- self.assertEqual(u'foo\xae', osutils.safe_unicode(b'foo\xc2\xae'))
661-
662- def test_bad_utf8_string(self):
663- self.assertRaises(errors.BzrBadParameterNotUnicode,
664- osutils.safe_unicode,
665- b'\xbb\xbb')
666-
667-
668-class TestSafeUtf8(tests.TestCase):
669-
670- def test_from_ascii_string(self):
671- f = b'foobar'
672- self.assertEqual(b'foobar', osutils.safe_utf8(f))
673-
674- def test_from_unicode_string_ascii_contents(self):
675- self.assertEqual(b'bargam', osutils.safe_utf8(u'bargam'))
676-
677- def test_from_unicode_string_unicode_contents(self):
678- self.assertEqual(b'bargam\xc2\xae', osutils.safe_utf8(u'bargam\xae'))
679-
680- def test_from_utf8_string(self):
681- self.assertEqual(b'foo\xc2\xae', osutils.safe_utf8(b'foo\xc2\xae'))
682-
683- def test_bad_utf8_string(self):
684- self.assertRaises(errors.BzrBadParameterNotUnicode,
685- osutils.safe_utf8, b'\xbb\xbb')
686-
687-
688 class TestSendAll(tests.TestCase):
689
690 def test_send_with_disconnected_socket(self):
691@@ -1129,7 +1089,7 @@
692 # (It would be ok if it happened earlier but at the moment it
693 # doesn't.)
694 e = self.assertRaises(OSError, list, osutils._walkdirs_utf8("."))
695- self.assertEqual('./test-unreadable', osutils.safe_unicode(e.filename))
696+ self.assertEqual(b'./test-unreadable', e.filename)
697 self.assertEqual(errno.EACCES, e.errno)
698 # Ensure the message contains the file name
699 self.assertContainsRe(str(e), "\\./test-unreadable")
700@@ -1202,7 +1162,7 @@
701 found_bzrdir = True
702 del dirblock[0]
703 dirdetail = (dirdetail[0].decode('utf-8'),
704- osutils.safe_unicode(dirdetail[1]))
705+ dirdetail[1])
706 dirblock = [
707 (entry[0].decode('utf-8'), entry[1].decode('utf-8'), entry[2])
708 for entry in dirblock]
709
710=== modified file 'breezy/tests/test_smtp_connection.py'
711--- breezy/tests/test_smtp_connection.py 2021-11-15 16:36:47 +0000
712+++ breezy/tests/test_smtp_connection.py 2022-10-27 08:09:03 +0000
713@@ -156,22 +156,24 @@
714 self.assertEqual(password, conn._smtp_password)
715
716 def test_authenticate_with_byte_strings(self):
717- user = b'joe'
718+ unicode_user = 'joe'
719 unicode_pass = u'h\xECspass'
720+ utf8_user = unicode_user.encode('utf-8')
721 utf8_pass = unicode_pass.encode('utf-8')
722 factory = WideOpenSMTPFactory()
723 conn = self.get_connection(
724 b'[DEFAULT]\nsmtp_username=%s\nsmtp_password=%s\n'
725- % (user, utf8_pass), smtp_factory=factory)
726+ % (utf8_user, utf8_pass), smtp_factory=factory)
727 self.assertEqual(unicode_pass, conn._smtp_password)
728 conn._connect()
729 self.assertEqual([('connect', 'localhost'),
730 ('ehlo',),
731 ('has_extn', 'starttls'),
732- ('login', user, utf8_pass)], factory._calls)
733+ ('login', unicode_user, unicode_pass)],
734+ factory._calls)
735 smtp_username, smtp_password = factory._calls[-1][1:]
736- self.assertIsInstance(smtp_username, bytes)
737- self.assertIsInstance(smtp_password, bytes)
738+ self.assertIsInstance(smtp_username, str)
739+ self.assertIsInstance(smtp_password, str)
740
741 def test_create_connection(self):
742 factory = StubSMTPFactory()
743
744=== modified file 'breezy/utextwrap.py'
745--- breezy/utextwrap.py 2020-02-18 01:57:45 +0000
746+++ breezy/utextwrap.py 2022-10-27 08:09:03 +0000
747@@ -249,7 +249,7 @@
748 return lines
749
750 def _split(self, text):
751- chunks = textwrap.TextWrapper._split(self, osutils.safe_unicode(text))
752+ chunks = textwrap.TextWrapper._split(self, text)
753 cjk_split_chunks = []
754 for chunk in chunks:
755 prev_pos = 0
756@@ -265,7 +265,7 @@
757
758 def wrap(self, text):
759 # ensure text is unicode
760- return textwrap.TextWrapper.wrap(self, osutils.safe_unicode(text))
761+ return textwrap.TextWrapper.wrap(self, text)
762
763 # -- Convenience interface ---------------------------------------------
764
765
766=== modified file 'breezy/workingtree.py'
767--- breezy/workingtree.py 2022-08-22 18:19:46 +0000
768+++ breezy/workingtree.py 2022-10-27 08:09:03 +0000
769@@ -109,7 +109,6 @@
770 if not _internal:
771 raise errors.BzrError("Please use controldir.open_workingtree or "
772 "WorkingTree.open() to obtain a WorkingTree.")
773- basedir = osutils.safe_unicode(basedir)
774 mutter("opening working tree %r", basedir)
775 if branch is not None:
776 self._branch = branch

Subscribers

People subscribed via source and target branches