Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Issue #578: Fix incompatibility between os.path.basename and the _os_…

…path_basename.
  • Loading branch information...
commit ecb2882796be1df981fe04505b21edbf8e083203 1 parent bb641dc
@matysek matysek authored
Showing with 29 additions and 6 deletions.
  1. +29 −6 PyInstaller/loader/pyi_iu.py
View
35 PyInstaller/loader/pyi_iu.py
@@ -629,12 +629,35 @@ def dirname(a, sep=sep, mindirlen=mindirlen):
return ''
if basename is None:
- def basename(p):
- i = p.rfind(sep)
- if i == -1:
- return p
- else:
- return p[i + len(sep):]
+ if sys.platform.startswith('win'):
+ # Implementation from ntpath.py module
+ # from standard Python 2.7 Library.
+ def basename(pth):
+ ## Implementation of os.path.splitdrive()
+ if pth[1:2] == ':':
+ d = pth[0:2]
+ p = pth[2:]
+ else:
+ d = ''
+ p = pth
+ ## Implementation of os.path.split()
+ # set i to index beyond p's last slash
+ i = len(p)
+ while i and p[i - 1] not in '/\\':
+ i = i - 1
+ head, tail = p[:i], p[i:] # now tail has no slashes
+ # remove trailing slashes from head, unless it's all slashes
+ head2 = head
+ while head2 and head2[-1] in '/\\':
+ head2 = head2[:-1]
+ head = head2 or head
+ return d + head, tail
+ else:
+ # Implementation from ntpath.py module
+ # from standard Python 2.7 Library.
+ def basename(pth):
+ i = pth.rfind('/') + 1
+ return pth[i:]
def _listdir(dir, cache=None):
# The cache is not used. It was found to cause problems
Please sign in to comment.
Something went wrong with that request. Please try again.