File tree Expand file tree Collapse file tree 5 files changed +12
-0
lines changed Expand file tree Collapse file tree 5 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -53,6 +53,8 @@ def join(s, *p):
53
53
try :
54
54
colon = _get_colon (s )
55
55
path = s
56
+ if not p :
57
+ path [:0 ] + colon #23780: Ensure compatible data type even if p is null.
56
58
for t in p :
57
59
if (not path ) or isabs (t ):
58
60
path = t
Original file line number Diff line number Diff line change @@ -81,6 +81,8 @@ def join(path, *paths):
81
81
seps = '\\ /'
82
82
colon = ':'
83
83
try :
84
+ if not paths :
85
+ path [:0 ] + sep #23780: Ensure compatible data type even if p is null.
84
86
result_drive , result_path = splitdrive (path )
85
87
for p in paths :
86
88
p_drive , p_path = splitdrive (p )
Original file line number Diff line number Diff line change @@ -76,6 +76,8 @@ def join(a, *p):
76
76
sep = _get_sep (a )
77
77
path = a
78
78
try :
79
+ if not p :
80
+ path [:0 ] + sep #23780: Ensure compatible data type even if p is null.
79
81
for b in p :
80
82
if b .startswith (sep ):
81
83
path = b
Original file line number Diff line number Diff line change @@ -448,6 +448,10 @@ def test_join_errors(self):
448
448
self .pathmodule .join (42 , 'str' )
449
449
with self .assertRaisesRegex (TypeError , errmsg % 'int' ):
450
450
self .pathmodule .join ('str' , 42 )
451
+ with self .assertRaisesRegex (TypeError , errmsg % 'int' ):
452
+ self .pathmodule .join (42 )
453
+ with self .assertRaisesRegex (TypeError , errmsg % 'list' ):
454
+ self .pathmodule .join ([])
451
455
with self .assertRaisesRegex (TypeError , errmsg % 'bytearray' ):
452
456
self .pathmodule .join (bytearray (b'foo' ), bytearray (b'bar' ))
453
457
Original file line number Diff line number Diff line change @@ -49,6 +49,8 @@ Core and Builtins
49
49
Library
50
50
-------
51
51
52
+ - Issue #23780: Improved error message in os.path.join() with single argument.
53
+
52
54
- Issue #6598: Increased time precision and random number range in
53
55
email.utils.make_msgid() to strengthen the uniqueness of the message ID.
54
56
You can’t perform that action at this time.
0 commit comments