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

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: no longer in the source branch.
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 :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'breezy/osutils.py'
--- breezy/osutils.py 2019-06-16 15:36:08 +0000
+++ breezy/osutils.py 2019-10-13 17:18:06 +0000
@@ -1026,24 +1026,32 @@
10261026
1027def splitpath(p):1027def splitpath(p):
1028 """Turn string into list of parts."""1028 """Turn string into list of parts."""
1029 use_bytes = isinstance(p, bytes)
1029 if os.path.sep == '\\':1030 if os.path.sep == '\\':
1030 # split on either delimiter because people might use either on1031 # split on either delimiter because people might use either on
1031 # Windows1032 # Windows
1032 if isinstance(p, bytes):1033 if use_bytes:
1033 ps = re.split(b'[\\\\/]', p)1034 ps = re.split(b'[\\\\/]', p)
1034 else:1035 else:
1035 ps = re.split(r'[\\/]', p)1036 ps = re.split(r'[\\/]', p)
1036 else:1037 else:
1037 if isinstance(p, bytes):1038 if use_bytes:
1038 ps = p.split(b'/')1039 ps = p.split(b'/')
1039 else:1040 else:
1040 ps = p.split('/')1041 ps = p.split('/')
10411042
1043 if use_bytes:
1044 parent_dir = b'..'
1045 current_empty_dir = (b'.', b'')
1046 else:
1047 parent_dir = '..'
1048 current_empty_dir = ('.', '')
1049
1042 rps = []1050 rps = []
1043 for f in ps:1051 for f in ps:
1044 if f in ('..', b'..'):1052 if f == parent_dir:
1045 raise errors.BzrError(gettext("sorry, %r not allowed in path") % f)1053 raise errors.BzrError(gettext("sorry, %r not allowed in path") % f)
1046 elif f in ('.', '', b'.', b''):1054 elif f in current_empty_dir:
1047 pass1055 pass
1048 else:1056 else:
1049 rps.append(f)1057 rps.append(f)

Subscribers

People subscribed via source and target branches