Skip to content

Commit 6632294

Browse files
gh-159240: Deprecate __{author,credits,copyright}__ attributes in stdlib modules (#159241)
1 parent 025fe55 commit 6632294

51 files changed

Lines changed: 505 additions & 282 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎Doc/deprecations/pending-removal-in-3.20.rst‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,27 @@ Pending removal in Python 3.20
3939

4040
(Contributed by Hugo van Kemenade and Stan Ulbrych in :gh:`76007`.)
4141

42+
* The ``__author__``, ``__credits__``, ``__copyright__`` and ``__date__``
43+
attributes have been deprecated in these standard library modules and will
44+
be removed in Python 3.20. Attribution is preserved in the source code
45+
and the version control history.
46+
47+
- :mod:`bz2`
48+
- :mod:`concurrent.futures`
49+
- :mod:`inspect`
50+
- :mod:`io`
51+
- :mod:`json`
52+
- :mod:`logging`
53+
- :mod:`optparse`
54+
- :mod:`platform`
55+
- :mod:`pydoc`
56+
- :mod:`tarfile`
57+
- :mod:`tkinter.ttk`
58+
- :mod:`tokenize`
59+
- :mod:`uuid`
60+
61+
(Contributed by Stan Ulbrych in :gh:`159240`.)
62+
4263
* Deprecations defined by :pep:`829`:
4364

4465
* Warnings are produced for ``import`` lines found in :file:`{name}.pth`

‎Doc/library/test.rst‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,6 +1087,14 @@ The :mod:`!test.support` module defines the following functions:
10871087

10881088
.. versionadded:: 3.6
10891089

1090+
1091+
.. function:: check_deprecated_module_attributes(test_case, module, *names, remove)
1092+
1093+
Assert that accessing each attribute in *names* on *module* emits a
1094+
:exc:`DeprecationWarning` naming the attribute and the Python version
1095+
*remove*, given as a ``(major, minor)`` tuple, in which it will be removed.
1096+
1097+
10901098
.. function:: skip_if_broken_multiprocessing_synchronize()
10911099

10921100
Skip tests if the :mod:`!multiprocessing.synchronize` module is missing, if

‎Doc/whatsnew/3.16.rst‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1192,6 +1192,29 @@ New deprecations
11921192
3.9, now issues a deprecation warning on use. This property is slated for
11931193
removal in 3.21. Use ``ast.Tuple.elts`` instead.
11941194

1195+
* ``__author__``, ``__credits__``, ``__copyright__`` and ``__date__``:
1196+
1197+
* The ``__author__``, ``__credits__``, ``__copyright__`` and ``__date__``
1198+
attributes have been deprecated in these standard library modules and will
1199+
be removed in Python 3.20. Attribution is preserved in the source code
1200+
and the version control history.
1201+
1202+
- :mod:`bz2`
1203+
- :mod:`concurrent.futures`
1204+
- :mod:`inspect`
1205+
- :mod:`io`
1206+
- :mod:`json`
1207+
- :mod:`logging`
1208+
- :mod:`optparse`
1209+
- :mod:`platform`
1210+
- :mod:`pydoc`
1211+
- :mod:`tarfile`
1212+
- :mod:`tkinter.ttk`
1213+
- :mod:`tokenize`
1214+
- :mod:`uuid`
1215+
1216+
(Contributed by Stan Ulbrych in :gh:`159240`.)
1217+
11951218
* :mod:`functools`:
11961219

11971220
* Using a return annotation to infer the dispatch type for

‎Lib/bz2.py‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@
88
"open", "compress", "decompress",
99
"bzlib_version", "bzlib_version_info"]
1010

11-
__author__ = "Nadeem Vawda <nadeem.vawda@gmail.com>"
11+
# Original author: Nadeem Vawda <nadeem.vawda@gmail.com>
1212

1313
from builtins import open as _builtin_open
1414
from compression._common import _streams
1515
import io
1616
import os
17+
lazy import warnings
1718

1819
from _bz2 import (BZ2Compressor, BZ2Decompressor,
1920
bzlib_version, bzlib_version_info)
@@ -352,3 +353,10 @@ def decompress(data):
352353
"end-of-stream marker was reached")
353354
data = decomp.unused_data
354355
return b"".join(results)
356+
357+
358+
def __getattr__(name):
359+
if name == "__author__":
360+
warnings._deprecated("__author__", remove=(3, 20))
361+
return "Nadeem Vawda <nadeem.vawda@gmail.com>" # Do not change
362+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")

‎Lib/concurrent/futures/__init__.py‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
"""Execute computations asynchronously using threads or processes."""
55

6-
__author__ = 'Brian Quinlan (brian@sweetapp.com)'
6+
# Original author: Brian Quinlan (brian@sweetapp.com)
77

88
from concurrent.futures._base import (FIRST_COMPLETED,
99
FIRST_EXCEPTION,
@@ -17,6 +17,7 @@
1717
wait,
1818
as_completed)
1919

20+
lazy import warnings
2021
lazy from .process import ProcessPoolExecutor
2122
lazy from .thread import ThreadPoolExecutor
2223

@@ -48,4 +49,11 @@
4849

4950

5051
def __dir__():
51-
return __all__ + ['__author__', '__doc__']
52+
return __all__ + ['__doc__']
53+
54+
55+
def __getattr__(name):
56+
if name == "__author__":
57+
warnings._deprecated("__author__", remove=(3, 20))
58+
return 'Brian Quinlan (brian@sweetapp.com)' # Do not change
59+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")

‎Lib/concurrent/futures/_base.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copyright 2009 Brian Quinlan. All Rights Reserved.
22
# Licensed to PSF under a Contributor Agreement.
33

4-
__author__ = 'Brian Quinlan (brian@sweetapp.com)'
4+
# Original author: Brian Quinlan (brian@sweetapp.com)
55

66
import collections
77
import logging

‎Lib/concurrent/futures/process.py‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
_ResultItems in "Result Q"
4444
"""
4545

46-
__author__ = 'Brian Quinlan (brian@sweetapp.com)'
46+
# Original author: Brian Quinlan (brian@sweetapp.com)
4747

4848
import os
4949
from concurrent.futures import _base
@@ -58,6 +58,7 @@
5858
from functools import partial
5959
import itertools
6060
import sys
61+
lazy import warnings
6162
from traceback import format_exception
6263

6364

@@ -1065,3 +1066,10 @@ def kill_workers(self):
10651066
submitted).
10661067
"""
10671068
return self._force_shutdown(operation=_KILL)
1069+
1070+
1071+
def __getattr__(name):
1072+
if name == "__author__":
1073+
warnings._deprecated("__author__", remove=(3, 20))
1074+
return 'Brian Quinlan (brian@sweetapp.com)' # Do not change
1075+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")

‎Lib/concurrent/futures/thread.py‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
"""Implements ThreadPoolExecutor."""
55

6-
__author__ = 'Brian Quinlan (brian@sweetapp.com)'
6+
# Original author: Brian Quinlan (brian@sweetapp.com)
77

88
from concurrent.futures import _base
99
import itertools
@@ -12,6 +12,7 @@
1212
import types
1313
import weakref
1414
import os
15+
lazy import warnings
1516

1617

1718
_threads_queues = weakref.WeakKeyDictionary()
@@ -272,3 +273,10 @@ def shutdown(self, wait=True, *, cancel_futures=False):
272273
for t in self._threads:
273274
t.join()
274275
shutdown.__doc__ = _base.Executor.shutdown.__doc__
276+
277+
278+
def __getattr__(name):
279+
if name == "__author__":
280+
warnings._deprecated("__author__", remove=(3, 20))
281+
return 'Brian Quinlan (brian@sweetapp.com)' # Do not change
282+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")

‎Lib/ctypes/_aix.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
The mode bit RTLD_MEMBER tells initAndLoad() that it needs to use the AIX (SVR3)
4545
naming style.
4646
"""
47-
__author__ = "Michael Felt <aixtools@felt.demon.nl>"
47+
# Original author: Michael Felt <aixtools@felt.demon.nl>
4848

4949
import re
5050
from os import environ, path

‎Lib/inspect.py‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828

2929
# This module is in the public domain. No warranties.
3030

31-
__author__ = ('Ka-Ping Yee <ping@lfw.org>',
32-
'Yury Selivanov <yselivanov@sprymix.com>')
31+
# Original authors: Ka-Ping Yee,
32+
# Yury Selivanov <yselivanov@sprymix.com>
3333

3434
__all__ = [
3535
"AGEN_CLOSED",
@@ -160,6 +160,7 @@
160160
import types
161161
import functools
162162
import builtins
163+
lazy import warnings
163164
from keyword import iskeyword
164165
from operator import attrgetter
165166
from collections import namedtuple, OrderedDict
@@ -3540,5 +3541,13 @@ def _main():
35403541
print(getsource(obj))
35413542

35423543

3544+
def __getattr__(name):
3545+
if name == "__author__":
3546+
warnings._deprecated("__author__", remove=(3, 20))
3547+
return ('Ka-Ping Yee',
3548+
'Yury Selivanov <yselivanov@sprymix.com>') # Do not change
3549+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
3550+
3551+
35433552
if __name__ == "__main__":
35443553
_main()

0 commit comments

Comments
 (0)