diff --git a/Lib/shutil.py b/Lib/shutil.py --- a/Lib/shutil.py +++ b/Lib/shutil.py @@ -2,17 +2,16 @@ XXX The functions here don't copy the resource fork or other metadata on Mac. """ import os import sys import stat -from os.path import abspath import fnmatch import collections import errno import tarfile try: import bz2 del bz2 @@ -34,16 +33,22 @@ except ImportError: "copytree", "move", "rmtree", "Error", "SpecialFileError", "ExecError", "make_archive", "get_archive_formats", "register_archive_format", "unregister_archive_format", "get_unpack_formats", "register_unpack_format", "unregister_unpack_format", "unpack_archive", "ignore_patterns", "chown", "which"] # disk_usage is added later, if available on the platform +def abspath(path): + import warnings + msg = "shutil.abspath is deprecated. Use os.path.abspath instead." + warnings.warn(msg, DeprecationWarning, stacklevel=2) + return os.path.abspath(path) + class Error(OSError): pass class SameFileError(Error): """Raised when source and destination are the same file.""" class SpecialFileError(OSError): """Raised when trying to do a kind of operation (e.g. copying) which is diff --git a/Lib/test/test_shutil.py b/Lib/test/test_shutil.py --- a/Lib/test/test_shutil.py +++ b/Lib/test/test_shutil.py @@ -1754,10 +1754,17 @@ class TermsizeTests(unittest.TestCase): with support.EnvironmentVarGuard() as env: del env['LINES'] del env['COLUMNS'] actual = shutil.get_terminal_size() self.assertEqual(expected, actual) +class TestDeprecatedFunctions(unittest.TestCase): + + def test_abspath(self): + with self.assertWarns(DeprecationWarning): + shutil.abspath('.') + + if __name__ == '__main__': unittest.main()