Skip to content

Commit 7a277ec

Browse files
committed
Use slicing
1 parent 9f464e8 commit 7a277ec

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Lib/importlib/_bootstrap_external.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,9 +295,10 @@ def cache_from_source(path, debug_override=None, *, optimization=None):
295295
head = _path_abspath(head)
296296

297297
# Strip initial drive from a Windows path. We know we have an absolute
298-
# path here, so the first part of the check rules out a POSIX path that
298+
# path here, so the second part of the check rules out a POSIX path that
299299
# happens to contain a colon at the second character.
300-
if head[0] not in path_separators and head[1] == ':':
300+
# Slicing avoids issues with an empty (or short) `head`.
301+
if head[1:2] == ':' and head[0:1] not in path_separators:
301302
head = head[2:]
302303

303304
# Strip initial path separator from `head` to complete the conversion

0 commit comments

Comments
 (0)