cpython: 84af71e8c051 (original) (raw)
Mercurial > cpython
changeset 96154:84af71e8c051
Issue #23780: Improved error message in os.path.join() with single argument. Idea by R. David Murray. [#23780]
Serhiy Storchaka storchaka@gmail.com | |
---|---|
date | Tue, 19 May 2015 11:00:07 +0300 |
parents | 933addbc7041 |
children | a3f2b171b765 |
files | Lib/macpath.py Lib/ntpath.py Lib/posixpath.py Lib/test/test_genericpath.py Misc/NEWS |
diffstat | 5 files changed, 12 insertions(+), 0 deletions(-)[+] [-] Lib/macpath.py 2 Lib/ntpath.py 2 Lib/posixpath.py 2 Lib/test/test_genericpath.py 4 Misc/NEWS 2 |
line wrap: on
line diff
--- a/Lib/macpath.py +++ b/Lib/macpath.py @@ -53,6 +53,8 @@ def join(s, *p): try: colon = _get_colon(s) path = s
if not p:[](#l1.7)
path[:0] + colon #23780: Ensure compatible data type even if p is null.[](#l1.8) for t in p:[](#l1.9) if (not path) or isabs(t):[](#l1.10) path = t[](#l1.11)
--- a/Lib/ntpath.py +++ b/Lib/ntpath.py @@ -81,6 +81,8 @@ def join(path, *paths): seps = '\/' colon = ':' try:
if not paths:[](#l2.7)
path[:0] + sep #23780: Ensure compatible data type even if p is null.[](#l2.8) result_drive, result_path = splitdrive(path)[](#l2.9) for p in paths:[](#l2.10) p_drive, p_path = splitdrive(p)[](#l2.11)
--- a/Lib/posixpath.py +++ b/Lib/posixpath.py @@ -76,6 +76,8 @@ def join(a, *p): sep = _get_sep(a) path = a try:
if not p:[](#l3.7)
path[:0] + sep #23780: Ensure compatible data type even if p is null.[](#l3.8) for b in p:[](#l3.9) if b.startswith(sep):[](#l3.10) path = b[](#l3.11)
--- a/Lib/test/test_genericpath.py +++ b/Lib/test/test_genericpath.py @@ -448,6 +448,10 @@ class CommonTest(GenericTest): self.pathmodule.join(42, 'str') with self.assertRaisesRegex(TypeError, errmsg % 'int'): self.pathmodule.join('str', 42)
with self.assertRaisesRegex(TypeError, errmsg % 'int'):[](#l4.7)
self.pathmodule.join(42)[](#l4.8)
with self.assertRaisesRegex(TypeError, errmsg % 'list'):[](#l4.9)
self.pathmodule.join([])[](#l4.10) with self.assertRaisesRegex(TypeError, errmsg % 'bytearray'):[](#l4.11) self.pathmodule.join(bytearray(b'foo'), bytearray(b'bar'))[](#l4.12)
--- a/Misc/NEWS +++ b/Misc/NEWS @@ -49,6 +49,8 @@ Core and Builtins Library ------- +- Issue #23780: Improved error message in os.path.join() with single argument. +