[Python-checkins] bpo-38807: Add os.PathLike to exception message raised by _check_arg_types (GH-17160) (GH-17249)
Raymond Hettinger
webhook-mailer at python.org
Tue Nov 19 01:46:18 EST 2019
https://github.com/python/cpython/commit/b5bb3b637c6b55f49d8979a5f489d01a67c4f917
commit: b5bb3b637c6b55f49d8979a5f489d01a67c4f917
branch: 3.8
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: Raymond Hettinger <rhettinger at users.noreply.github.com>
date: 2019-11-18T22:46:10-08:00
summary:
bpo-38807: Add os.PathLike to exception message raised by _check_arg_types (GH-17160) (GH-17249)
(cherry picked from commit fe75b62575bcfdf1c39be71c1e50257832a596db)
Co-authored-by: Tomás Farías <tomasfariassantana at gmail.com>
files:
A Misc/NEWS.d/next/Library/2019-11-15-09-30-29.bpo-38807.PsmRog.rst
M Lib/genericpath.py
diff --git a/Lib/genericpath.py b/Lib/genericpath.py
index db11f67d54cc2..ce36451a3af01 100644
--- a/Lib/genericpath.py
+++ b/Lib/genericpath.py
@@ -149,7 +149,7 @@ def _check_arg_types(funcname, *args):
elif isinstance(s, bytes):
hasbytes = True
else:
- raise TypeError('%s() argument must be str or bytes, not %r' %
- (funcname, s.__class__.__name__)) from None
+ raise TypeError(f'{funcname}() argument must be str, bytes, or '
+ f'os.PathLike object, not {s.__class__.__name__!r}') from None
if hasstr and hasbytes:
raise TypeError("Can't mix strings and bytes in path components") from None
diff --git a/Misc/NEWS.d/next/Library/2019-11-15-09-30-29.bpo-38807.PsmRog.rst b/Misc/NEWS.d/next/Library/2019-11-15-09-30-29.bpo-38807.PsmRog.rst
new file mode 100644
index 0000000000000..2bd7e3deb19ed
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2019-11-15-09-30-29.bpo-38807.PsmRog.rst
@@ -0,0 +1 @@
+Update :exc:`TypeError` messages for :meth:`os.path.join` to include :class:`os.PathLike` objects as acceptable input types.
\ No newline at end of file
More information about the Python-checkins
mailing list