diff --git a/Lib/ntpath.py b/Lib/ntpath.py index 8f5dc55bec5..ee1a2157a14 100644 --- a/Lib/ntpath.py +++ b/Lib/ntpath.py @@ -584,7 +584,7 @@ def relpath(path, start=None): if not rel_list: return curdir return join(*rel_list) - except (TypeError, ValueError, AttributeError, BytesWarning): + except (TypeError, ValueError, AttributeError, BytesWarning, DeprecationWarning): genericpath._check_arg_types('relpath', path, start) raise diff --git a/Lib/posixpath.py b/Lib/posixpath.py index ce5f7928cc7..44ed8383f2e 100644 --- a/Lib/posixpath.py +++ b/Lib/posixpath.py @@ -452,6 +452,6 @@ def relpath(path, start=None): if not rel_list: return curdir return join(*rel_list) - except (TypeError, AttributeError, BytesWarning): + except (TypeError, AttributeError, BytesWarning, DeprecationWarning): genericpath._check_arg_types('relpath', path, start) raise diff --git a/Lib/test/test_genericpath.py b/Lib/test/test_genericpath.py index 2e31fe42362..f2722bcc8a5 100644 --- a/Lib/test/test_genericpath.py +++ b/Lib/test/test_genericpath.py @@ -453,7 +453,8 @@ class CommonTest(GenericTest): def test_relpath_errors(self): # Check relpath() raises friendly TypeErrors. - with support.check_warnings(('', BytesWarning), quiet=True): + with support.check_warnings(('', (BytesWarning, DeprecationWarning)), + quiet=True): errmsg = "Can't mix strings and bytes in path components" with self.assertRaisesRegex(TypeError, errmsg): self.pathmodule.relpath(b'bytes', 'str')