Merge lp:~jelmer/brz/no-safe-unicode into lp:brz/3.2
- no-safe-unicode
- Merge into 3.2
Proposed by
Jelmer Vernooij
Status: | Superseded |
---|---|
Proposed branch: | lp:~jelmer/brz/no-safe-unicode |
Merge into: | lp:brz/3.2 |
Diff against target: |
767 lines (+70/-196) 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 (+4/-37) 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 (+1/-1) 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) |
To merge this branch: | bzr merge lp:~jelmer/brz/no-safe-unicode |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jelmer Vernooij | Approve | ||
Review via email: mp+413479@code.launchpad.net |
This proposal has been superseded by a proposal from 2022-10-27.
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) : | # |
review:
Approve
Revision history for this message
The Breezy Bot (the-breezy-bot) wrote : | # |
Revision history for this message
The Breezy Bot (the-breezy-bot) wrote : | # |
Running landing tests failed
https:/
Revision history for this message
The Breezy Bot (the-breezy-bot) wrote : | # |
Running landing tests failed
https:/
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 2021-12-25 01:38:23 +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 2020-07-18 23:14:00 +0000 |
21 | +++ breezy/bzr/tests/per_versionedfile.py 2021-12-25 01:38:23 +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 2021-08-19 21:03:45 +0000 |
51 | +++ breezy/bzr/versionedfile.py 2021-12-25 01:38:23 +0000 |
52 | @@ -550,13 +550,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 | @@ -1171,13 +1171,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 2020-11-18 02:15:43 +0000 |
87 | +++ breezy/bzr/workingtree_3.py 2021-12-25 01:38:23 +0000 |
88 | @@ -79,8 +79,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 2020-11-18 02:15:43 +0000 |
101 | +++ breezy/bzr/workingtree_4.py 2021-12-25 01:38:23 +0000 |
102 | @@ -71,7 +71,6 @@ |
103 | isdir, |
104 | pathjoin, |
105 | realpath, |
106 | - safe_unicode, |
107 | ) |
108 | from ..transport import get_transport_from_path |
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 2021-05-02 15:07:21 +0000 |
138 | +++ breezy/config.py 2021-12-25 01:38:23 +0000 |
139 | @@ -941,7 +941,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 2021-12-25 01:38:23 +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 2021-08-19 16:05:04 +0000 |
191 | +++ breezy/errors.py 2021-12-25 01:38:23 +0000 |
192 | @@ -1474,23 +1474,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 | @@ -1536,27 +1519,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 2021-05-02 15:07:21 +0000 |
247 | +++ breezy/git/branch.py 2021-12-25 01:38:23 +0000 |
248 | @@ -1200,8 +1200,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 2020-07-18 23:14:00 +0000 |
262 | +++ breezy/git/fetch.py 2021-12-25 01:38:23 +0000 |
263 | @@ -258,7 +258,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 2020-02-18 01:57:45 +0000 |
275 | +++ breezy/git/refs.py 2021-12-25 01:38:23 +0000 |
276 | @@ -59,7 +59,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 | @@ -68,18 +68,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 2021-12-25 01:38:23 +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 2021-04-03 12:58:34 +0000 |
326 | +++ breezy/git/tests/test_remote.py 2021-12-25 01:38:23 +0000 |
327 | @@ -675,7 +675,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 2021-12-09 20:50:25 +0000 |
339 | +++ breezy/git/tree.py 2021-12-25 01:38:23 +0000 |
340 | @@ -402,7 +402,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_file_ids(self): |
348 | raise errors.UnsupportedOperation(self.all_file_ids, self) |
349 | @@ -1163,8 +1163,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 id2path(self, file_id, recurse='down'): |
359 | |
360 | === modified file 'breezy/gpg.py' |
361 | --- breezy/gpg.py 2021-01-10 00:25:52 +0000 |
362 | +++ breezy/gpg.py 2021-12-25 01:38:23 +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 2021-12-24 17:11:16 +0000 |
375 | +++ breezy/osutils.py 2021-12-25 01:38:23 +0000 |
376 | @@ -1335,40 +1335,6 @@ |
377 | raise errors.BadFilenameEncoding(filename, _fs_enc) |
378 | |
379 | |
380 | -def safe_unicode(unicode_or_utf8_string): |
381 | - """Coerce unicode_or_utf8_string into unicode. |
382 | - |
383 | - If it is unicode, it is returned. |
384 | - Otherwise it is decoded from utf-8. If decoding fails, the exception is |
385 | - wrapped in a BzrBadParameterNotUnicode exception. |
386 | - """ |
387 | - if isinstance(unicode_or_utf8_string, str): |
388 | - return unicode_or_utf8_string |
389 | - try: |
390 | - return unicode_or_utf8_string.decode('utf8') |
391 | - except UnicodeDecodeError: |
392 | - raise errors.BzrBadParameterNotUnicode(unicode_or_utf8_string) |
393 | - |
394 | - |
395 | -def safe_utf8(unicode_or_utf8_string): |
396 | - """Coerce unicode_or_utf8_string to a utf8 string. |
397 | - |
398 | - If it is a str, it is returned. |
399 | - If it is Unicode, it is encoded into a utf-8 string. |
400 | - """ |
401 | - if isinstance(unicode_or_utf8_string, bytes): |
402 | - # TODO: jam 20070209 This is overkill, and probably has an impact on |
403 | - # performance if we are dealing with lots of apis that want a |
404 | - # utf-8 revision id |
405 | - try: |
406 | - # Make sure it is a valid utf-8 string |
407 | - unicode_or_utf8_string.decode('utf-8') |
408 | - except UnicodeDecodeError: |
409 | - raise errors.BzrBadParameterNotUnicode(unicode_or_utf8_string) |
410 | - return unicode_or_utf8_string |
411 | - return unicode_or_utf8_string.encode('utf-8') |
412 | - |
413 | - |
414 | _platform_normalizes_filenames = False |
415 | if sys.platform == 'darwin': |
416 | _platform_normalizes_filenames = True |
417 | @@ -1738,7 +1704,7 @@ |
418 | # potentially confusing output. We should make this more robust - but |
419 | # not at a speed cost. RBC 20060731 |
420 | _directory = _directory_kind |
421 | - pending = [(safe_unicode(prefix), "", _directory, None, safe_unicode(top))] |
422 | + pending = [(prefix, "", _directory, None, top)] |
423 | while pending: |
424 | # 0 - relpath, 1- basename, 2- kind, 3- stat, 4-toppath |
425 | relroot, _, _, _, top = pending.pop() |
426 | @@ -1856,7 +1822,8 @@ |
427 | |
428 | def top_prefix_to_starting_dir(self, top, prefix=""): |
429 | """See DirReader.top_prefix_to_starting_dir.""" |
430 | - return (safe_utf8(prefix), None, None, None, safe_unicode(top)) |
431 | + return (prefix.encode('utf-8') |
432 | + if isinstance(prefix, str) else prefix, None, None, None, top) |
433 | |
434 | def read_dir(self, prefix, top): |
435 | """Read a single directory from a non-utf8 file system. |
436 | @@ -1885,7 +1852,7 @@ |
437 | |
438 | dirblock = [] |
439 | append = dirblock.append |
440 | - for entry in scandir(safe_utf8(top)): |
441 | + for entry in scandir(_fs_encode(top)): |
442 | try: |
443 | name = _fs_decode(entry.name) |
444 | except UnicodeDecodeError: |
445 | |
446 | === modified file 'breezy/plugins/launchpad/lp_api.py' |
447 | --- breezy/plugins/launchpad/lp_api.py 2020-07-28 02:11:05 +0000 |
448 | +++ breezy/plugins/launchpad/lp_api.py 2021-12-25 01:38:23 +0000 |
449 | @@ -271,7 +271,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 2021-12-25 01:38:23 +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 2020-06-10 23:47:24 +0000 |
558 | +++ breezy/plugins/weave_fmt/repository.py 2021-12-25 01:38:23 +0000 |
559 | @@ -87,7 +87,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 2021-12-25 01:38:23 +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 2020-06-19 21:26:53 +0000 |
591 | +++ breezy/tests/blackbox/test_export.py 2021-12-25 01:38:23 +0000 |
592 | @@ -114,7 +114,7 @@ |
593 | ball = tarfile.open('test.tar') |
594 | # all paths are prefixed with the base name of the tarball |
595 | self.assertEqual([u'test/' + fname], |
596 | - [osutils.safe_unicode(n) for n in ball.getnames()]) |
597 | + [n for n in ball.getnames()]) |
598 | |
599 | def test_tar_export_unicode_basedir(self): |
600 | """Test for bug #413406""" |
601 | |
602 | === modified file 'breezy/tests/test_email_message.py' |
603 | --- breezy/tests/test_email_message.py 2020-02-07 02:14:30 +0000 |
604 | +++ breezy/tests/test_email_message.py 2021-12-25 01:38:23 +0000 |
605 | @@ -19,7 +19,6 @@ |
606 | |
607 | from .. import __version__ as _breezy_version |
608 | from ..email_message import EmailMessage |
609 | -from ..errors import BzrBadParameterNotUnicode |
610 | from ..smtp_connection import SMTPConnection |
611 | from .. import tests |
612 | |
613 | @@ -133,7 +132,7 @@ |
614 | for i in range(3): # from_address, to_address, subject |
615 | x = [b'"J. Random Developer" <jrandom@example.com>'] * 3 |
616 | x[i] = b'Pepe P\xe9rez <pperez@ejemplo.com>' |
617 | - self.assertRaises(BzrBadParameterNotUnicode, EmailMessage, *x) |
618 | + self.assertRaises(TypeError, EmailMessage, *x) |
619 | |
620 | def test_multiple_destinations(self): |
621 | to_addresses = ['to1@to.com', 'to2@to.com', 'to3@to.com'] |
622 | @@ -183,7 +182,7 @@ |
623 | self.assertEqual(address, decode(encoded)) |
624 | |
625 | address = b'Pepe P\xe9rez <pperez@ejemplo.com>' # ISO-8859-1 not ok |
626 | - self.assertRaises(BzrBadParameterNotUnicode, |
627 | + self.assertRaises(TypeError, |
628 | EmailMessage.address_to_encoded_header, address) |
629 | |
630 | def test_string_with_encoding(self): |
631 | |
632 | === modified file 'breezy/tests/test_osutils.py' |
633 | --- breezy/tests/test_osutils.py 2021-12-24 15:16:39 +0000 |
634 | +++ breezy/tests/test_osutils.py 2021-12-25 01:38:23 +0000 |
635 | @@ -778,46 +778,6 @@ |
636 | osutils.relpath, 'C:/', 'H:/path') |
637 | |
638 | |
639 | -class TestSafeUnicode(tests.TestCase): |
640 | - |
641 | - def test_from_ascii_string(self): |
642 | - self.assertEqual(u'foobar', osutils.safe_unicode(b'foobar')) |
643 | - |
644 | - def test_from_unicode_string_ascii_contents(self): |
645 | - self.assertEqual(u'bargam', osutils.safe_unicode(u'bargam')) |
646 | - |
647 | - def test_from_unicode_string_unicode_contents(self): |
648 | - self.assertEqual(u'bargam\xae', osutils.safe_unicode(u'bargam\xae')) |
649 | - |
650 | - def test_from_utf8_string(self): |
651 | - self.assertEqual(u'foo\xae', osutils.safe_unicode(b'foo\xc2\xae')) |
652 | - |
653 | - def test_bad_utf8_string(self): |
654 | - self.assertRaises(errors.BzrBadParameterNotUnicode, |
655 | - osutils.safe_unicode, |
656 | - b'\xbb\xbb') |
657 | - |
658 | - |
659 | -class TestSafeUtf8(tests.TestCase): |
660 | - |
661 | - def test_from_ascii_string(self): |
662 | - f = b'foobar' |
663 | - self.assertEqual(b'foobar', osutils.safe_utf8(f)) |
664 | - |
665 | - def test_from_unicode_string_ascii_contents(self): |
666 | - self.assertEqual(b'bargam', osutils.safe_utf8(u'bargam')) |
667 | - |
668 | - def test_from_unicode_string_unicode_contents(self): |
669 | - self.assertEqual(b'bargam\xc2\xae', osutils.safe_utf8(u'bargam\xae')) |
670 | - |
671 | - def test_from_utf8_string(self): |
672 | - self.assertEqual(b'foo\xc2\xae', osutils.safe_utf8(b'foo\xc2\xae')) |
673 | - |
674 | - def test_bad_utf8_string(self): |
675 | - self.assertRaises(errors.BzrBadParameterNotUnicode, |
676 | - osutils.safe_utf8, b'\xbb\xbb') |
677 | - |
678 | - |
679 | class TestSendAll(tests.TestCase): |
680 | |
681 | def test_send_with_disconnected_socket(self): |
682 | @@ -1136,7 +1096,7 @@ |
683 | # (It would be ok if it happened earlier but at the moment it |
684 | # doesn't.) |
685 | e = self.assertRaises(OSError, list, osutils._walkdirs_utf8(".")) |
686 | - self.assertEqual('./test-unreadable', osutils.safe_unicode(e.filename)) |
687 | + self.assertEqual(b'./test-unreadable', e.filename) |
688 | self.assertEqual(errno.EACCES, e.errno) |
689 | # Ensure the message contains the file name |
690 | self.assertContainsRe(str(e), "\\./test-unreadable") |
691 | @@ -1210,7 +1170,7 @@ |
692 | found_bzrdir = True |
693 | del dirblock[0] |
694 | dirdetail = (dirdetail[0].decode('utf-8'), |
695 | - osutils.safe_unicode(dirdetail[1])) |
696 | + dirdetail[1]) |
697 | dirblock = [ |
698 | (entry[0].decode('utf-8'), entry[1].decode('utf-8'), entry[2]) |
699 | for entry in dirblock] |
700 | |
701 | === modified file 'breezy/tests/test_smtp_connection.py' |
702 | --- breezy/tests/test_smtp_connection.py 2021-11-15 16:36:47 +0000 |
703 | +++ breezy/tests/test_smtp_connection.py 2021-12-25 01:38:23 +0000 |
704 | @@ -156,22 +156,24 @@ |
705 | self.assertEqual(password, conn._smtp_password) |
706 | |
707 | def test_authenticate_with_byte_strings(self): |
708 | - user = b'joe' |
709 | + unicode_user = 'joe' |
710 | unicode_pass = u'h\xECspass' |
711 | + utf8_user = unicode_user.encode('utf-8') |
712 | utf8_pass = unicode_pass.encode('utf-8') |
713 | factory = WideOpenSMTPFactory() |
714 | conn = self.get_connection( |
715 | b'[DEFAULT]\nsmtp_username=%s\nsmtp_password=%s\n' |
716 | - % (user, utf8_pass), smtp_factory=factory) |
717 | + % (utf8_user, utf8_pass), smtp_factory=factory) |
718 | self.assertEqual(unicode_pass, conn._smtp_password) |
719 | conn._connect() |
720 | self.assertEqual([('connect', 'localhost'), |
721 | ('ehlo',), |
722 | ('has_extn', 'starttls'), |
723 | - ('login', user, utf8_pass)], factory._calls) |
724 | + ('login', unicode_user, unicode_pass)], |
725 | + factory._calls) |
726 | smtp_username, smtp_password = factory._calls[-1][1:] |
727 | - self.assertIsInstance(smtp_username, bytes) |
728 | - self.assertIsInstance(smtp_password, bytes) |
729 | + self.assertIsInstance(smtp_username, str) |
730 | + self.assertIsInstance(smtp_password, str) |
731 | |
732 | def test_create_connection(self): |
733 | factory = StubSMTPFactory() |
734 | |
735 | === modified file 'breezy/utextwrap.py' |
736 | --- breezy/utextwrap.py 2020-02-18 01:57:45 +0000 |
737 | +++ breezy/utextwrap.py 2021-12-25 01:38:23 +0000 |
738 | @@ -249,7 +249,7 @@ |
739 | return lines |
740 | |
741 | def _split(self, text): |
742 | - chunks = textwrap.TextWrapper._split(self, osutils.safe_unicode(text)) |
743 | + chunks = textwrap.TextWrapper._split(self, text) |
744 | cjk_split_chunks = [] |
745 | for chunk in chunks: |
746 | prev_pos = 0 |
747 | @@ -265,7 +265,7 @@ |
748 | |
749 | def wrap(self, text): |
750 | # ensure text is unicode |
751 | - return textwrap.TextWrapper.wrap(self, osutils.safe_unicode(text)) |
752 | + return textwrap.TextWrapper.wrap(self, text) |
753 | |
754 | # -- Convenience interface --------------------------------------------- |
755 | |
756 | |
757 | === modified file 'breezy/workingtree.py' |
758 | --- breezy/workingtree.py 2020-11-18 02:15:43 +0000 |
759 | +++ breezy/workingtree.py 2021-12-25 01:38:23 +0000 |
760 | @@ -108,7 +108,6 @@ |
761 | if not _internal: |
762 | raise errors.BzrError("Please use controldir.open_workingtree or " |
763 | "WorkingTree.open() to obtain a WorkingTree.") |
764 | - basedir = osutils.safe_unicode(basedir) |
765 | mutter("opening working tree %r", basedir) |
766 | if branch is not None: |
767 | self._branch = branch |
Running landing tests failed /ci.breezy- vcs.org/ job/brz- 3.2/job/ brz-3.2- land/72/
https:/