* :mod:`symtable`:
Deprecate :meth:`symtable.Class.get_methods` due to the lack of interest.
(Contributed by Bénédikt Tran in :gh:`119698`.)
+
+* :mod:`shutil`: Deprecate :class:`!shutil.ExecError`, which hasn't
+ been raised by any :mod:`!shutil` function since Python 3.4. It's
+ now an alias for :exc:`RuntimeError`.
+
__all__ = ["copyfileobj", "copyfile", "copymode", "copystat", "copy", "copy2",
"copytree", "move", "rmtree", "Error", "SpecialFileError",
- "ExecError", "make_archive", "get_archive_formats",
+ "make_archive", "get_archive_formats",
"register_archive_format", "unregister_archive_format",
"get_unpack_formats", "register_unpack_format",
"unregister_unpack_format", "unpack_archive",
"""Raised when trying to do a kind of operation (e.g. copying) which is
not supported on a special file (e.g. a named pipe)"""
-class ExecError(OSError):
- """Raised when a command could not be executed"""
class ReadError(OSError):
"""Raised when an archive cannot be read"""
if _access_check(name, mode):
return name
return None
+
+def __getattr__(name):
+ if name == "ExecError":
+ import warnings
+ warnings._deprecated(
+ "shutil.ExecError",
+ f"{warnings._DEPRECATED_MSG}; it "
+ "isn't raised by any shutil function.",
+ remove=(3, 16)
+ )
+ return RuntimeError
+ raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
self.assertTrue(hasattr(shutil, '__all__'))
target_api = ['copyfileobj', 'copyfile', 'copymode', 'copystat',
'copy', 'copy2', 'copytree', 'move', 'rmtree', 'Error',
- 'SpecialFileError', 'ExecError', 'make_archive',
+ 'SpecialFileError', 'make_archive',
'get_archive_formats', 'register_archive_format',
'unregister_archive_format', 'get_unpack_formats',
'register_unpack_format', 'unregister_unpack_format',
if hasattr(os, 'statvfs') or os.name == 'nt':
target_api.append('disk_usage')
self.assertEqual(set(shutil.__all__), set(target_api))
+ with self.assertWarns(DeprecationWarning):
+ from shutil import ExecError
if __name__ == '__main__':
--- /dev/null
+Deprecate :class:`!shutil.ExecError`, which hasn't been
+raised by any :mod:`shutil` function since Python 3.4. It's
+now an alias for :exc:`RuntimeError`.
+