Merge lp:~jelmer/brz/python3.8-1 into lp:brz

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: 7399
Merge reported by: The Breezy Bot
Merged at revision: not available
Proposed branch: lp:~jelmer/brz/python3.8-1
Merge into: lp:brz
Diff against target: 40 lines (+12/-4)
1 file modified
breezy/osutils.py (+12/-4)
To merge this branch: bzr merge lp:~jelmer/brz/python3.8-1
Reviewer Review Type Date Requested Status
Martin Packman Approve
Review via email: mp+374051@code.launchpad.net

Commit message

Support passing bytestring paths to osutils.splitpath.

Description of the change

Support passing bytestring paths to osutils.splitpath.

This fixes some of the tests on Python 3.8.

To post a comment you must log in.
Revision history for this message
Martin Packman (gz) wrote :

Thanks!

review: Approve
Revision history for this message
The Breezy Bot (the-breezy-bot) wrote :
lp:~jelmer/brz/python3.8-1 updated
7399. By Jelmer Vernooij

Fix test.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'breezy/osutils.py'
2--- breezy/osutils.py 2019-06-16 15:36:08 +0000
3+++ breezy/osutils.py 2019-10-13 17:18:06 +0000
4@@ -1026,24 +1026,32 @@
5
6 def splitpath(p):
7 """Turn string into list of parts."""
8+ use_bytes = isinstance(p, bytes)
9 if os.path.sep == '\\':
10 # split on either delimiter because people might use either on
11 # Windows
12- if isinstance(p, bytes):
13+ if use_bytes:
14 ps = re.split(b'[\\\\/]', p)
15 else:
16 ps = re.split(r'[\\/]', p)
17 else:
18- if isinstance(p, bytes):
19+ if use_bytes:
20 ps = p.split(b'/')
21 else:
22 ps = p.split('/')
23
24+ if use_bytes:
25+ parent_dir = b'..'
26+ current_empty_dir = (b'.', b'')
27+ else:
28+ parent_dir = '..'
29+ current_empty_dir = ('.', '')
30+
31 rps = []
32 for f in ps:
33- if f in ('..', b'..'):
34+ if f == parent_dir:
35 raise errors.BzrError(gettext("sorry, %r not allowed in path") % f)
36- elif f in ('.', '', b'.', b''):
37+ elif f in current_empty_dir:
38 pass
39 else:
40 rps.append(f)

Subscribers

People subscribed via source and target branches