Repository navigation
Fix/silence doctest warnings #94001
Copy link
Copy link
Closed
Labels
3.11only security fixesonly security fixes3.12only security fixesonly security fixes3.13only security fixesonly security fixespendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is providedtestsTests in the Lib/test dirTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
I noticed a few warnings triggered during the Doctest workflows. These should be either fixed by updating/removing the examples, or possibly silenced.
These are the (collapsed) outputs on main/3.11/3.10:
main
From https://github.com/python/cpython/runs/6946479177?check_suite_focus=true
make: Entering directory '/home/runner/work/cpython/cpython/Doc'
make[1]: Entering directory '/home/runner/work/cpython/cpython/Doc'
mkdir -p build
Building NEWS from Misc/NEWS.d with blurb
PATH=./venv/bin:$PATH sphinx-build -b doctest -d build/doctrees -j auto -q -W --keep-going . build/doctest
/home/runner/work/cpython/cpython/Doc/venv/lib/python3.12/site-packages/babel/messages/catalog.py:13: DeprecationWarning: 'cgi' is deprecated and slated for removal in Python 3.13
from cgi import parse_header
/home/runner/work/cpython/cpython/Doc/venv/lib/python3.12/site-packages/sphinx/util/images.py:4: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13
import imghdr
/home/runner/work/cpython/cpython/Doc/venv/lib/python3.12/site-packages/certifi/core.py:36: DeprecationWarning: path is deprecated. Use files() instead. Refer to https://importlib-resources.readthedocs.io/en/latest/using.html#migrating-from-legacy for migration advice.
_CACERT_CTX = get_path("certifi", "cacert.pem")
<doctest default[0]>:1: DeprecationWarning: 'nntplib' is deprecated and slated for removal in Python 3.13
from nntplib import NNTP
/home/runner/work/cpython/cpython/Lib/socket.py:777: ResourceWarning: unclosed <socket.socket fd=4, family=2, type=1, proto=6, laddr=('10.1.0.37', 45010), raddr=('116.202.254.214', 119)>
self._sock = None
ResourceWarning: Enable tracemalloc to get the object allocation traceback
<doctest default[0]>:1: DeprecationWarning: the imp module is deprecated in favour of importlib and slated for removal in Python 3.12; see the module's documentation for alternative uses
import imp
<doctest default[3]>:1: DeprecationWarning: 'turtle.RawTurtle.settiltangle()' is deprecated since Python 3.1 and scheduled for removal in Python 3.13. Use tiltangle() instead.
turtle.settiltangle(45)3.11
From https://github.com/python/cpython/runs/6954035375?check_suite_focus=true
make: Entering directory '/home/runner/work/cpython/cpython/Doc'
make[1]: Entering directory '/home/runner/work/cpython/cpython/Doc'
mkdir -p build
Building NEWS from Misc/NEWS.d with blurb
PATH=./venv/bin:$PATH sphinx-build -b doctest -d build/doctrees -j auto -q -W --keep-going . build/doctest
/home/runner/work/cpython/cpython/Doc/venv/lib/python3.11/site-packages/babel/messages/catalog.py:13: DeprecationWarning: 'cgi' is deprecated and slated for removal in Python 3.13
from cgi import parse_header
/home/runner/work/cpython/cpython/Doc/venv/lib/python3.11/site-packages/sphinx/util/images.py:4: DeprecationWarning: 'imghdr' is deprecated and slated for removal in Python 3.13
import imghdr
/home/runner/work/cpython/cpython/Doc/venv/lib/python3.11/site-packages/certifi/core.py:36: DeprecationWarning: path is deprecated. Use files() instead. Refer to https://importlib-resources.readthedocs.io/en/latest/using.html#migrating-from-legacy for migration advice.
_CACERT_CTX = get_path("certifi", "cacert.pem")
<doctest default[0]>:1: DeprecationWarning: 'nntplib' is deprecated and slated for removal in Python 3.13
from nntplib import NNTP
/home/runner/work/cpython/cpython/Lib/socket.py:776: ResourceWarning: unclosed <socket.socket fd=4, family=2, type=1, proto=6, laddr=('10.1.0.43', 48872), raddr=('116.202.254.214', 119)>
self._sock = None
ResourceWarning: Enable tracemalloc to get the object allocation traceback
<doctest default[3]>:1: DeprecationWarning: 'turtle.RawTurtle.settiltangle()' is deprecated since Python 3.1 and scheduled for removal in Python 3.13. Use tiltangle() instead.
turtle.settiltangle(45)
<doctest default[0]>:1: DeprecationWarning: the imp module is deprecated in favour of importlib and slated for removal in Python 3.12; see the module's documentation for alternative uses
import imp3.10
From https://github.com/python/cpython/runs/6954044919?check_suite_focus=true
make: Entering directory '/home/runner/work/cpython/cpython/Doc'
make[1]: Entering directory '/home/runner/work/cpython/cpython/Doc'
mkdir -p build
Building NEWS from Misc/NEWS.d with blurb
PATH=./venv/bin:$PATH sphinx-build -b doctest -d build/doctrees -j auto -q -W --keep-going . build/doctest
/home/runner/work/cpython/cpython/Doc/venv/lib/python3.10/site-packages/sphinx/util/docutils.py:45: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
__version_info__ = tuple(LooseVersion(docutils.__version__).version)
/home/runner/work/cpython/cpython/Doc/venv/lib/python3.10/site-packages/sphinx/util/rst.py:56: DeprecationWarning: 'environmentfilter' is renamed to 'pass_environment', the old name will be removed in Jinja 3.1.
def heading(env: Environment, text: str, level: int = 1) -> str:
/home/runner/work/cpython/cpython/Doc/venv/lib/python3.10/site-packages/sphinx/jinja2glue.py:106: DeprecationWarning: 'contextfunction' is renamed to 'pass_context', the old name will be removed in Jinja 3.1.
def warning(context: Dict, message: str, *args: Any, **kwargs: Any) -> str:
<doctest default[0]>:1: DeprecationWarning: the imp module is deprecated in favour of importlib and slated for removal in Python 3.12; see the module's documentation for alternative uses
import imp
/home/runner/work/cpython/cpython/Lib/socket.py:776: ResourceWarning: unclosed <socket.socket fd=4, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('10.1.1.51', 47304), raddr=('116.202.254.214', 119)>
self._sock = None
ResourceWarning: Enable tracemalloc to get the object allocation traceback
<doctest default[2]>:1: DeprecationWarning: `formatargspec` is deprecated since Python 3.5. Use `signature` and the `Signature` object directly
formatargspec(*getfullargspec(f))Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
3.11only security fixesonly security fixes3.12only security fixesonly security fixes3.13only security fixesonly security fixespendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is providedtestsTests in the Lib/test dirTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Activity
CAM-Gerlach commentedon Jun 19, 2022
The stdlib's tests use the
_ignore_deprecated_importscontext manager; if a doctest example is for the deprecated module itself, that could be used in a hidden block, if it involves another module using the deprecated module, the example/doctest should be updated to use a replacement (or removed, if not possible).It seems several warnings are for third party projects (Sphinx, etc) using stdlib modules that are deprecated; in that case, those projects should be updated.
In 3.10, the warnings look to be due to Sphinx 3.x using names deprecated in Jinja 3.x. Either it should be upgrade to use Sphinx 4, or jinja should be upper capped at
<3.hugovk commentedon Jun 26, 2022
Third-party deprecation warnings in
mainand 3.11:Fixed in python-babel/babel#876, pending release.
Edit: ✅ Released in Babel 2.11.0!
Pending issue: sphinx-doc/sphinx#10440
Edit: ✅ Released in Sphinx 6.2.0!
PR pending merge: certifi/python-certifi#193
Edit: ✅ Merged via certifi/python-certifi#199 and released in Certifi 2022.06.15.1!
arhadthedev commentedon May 25, 2023
Current status (from https://github.com/python/cpython/actions/runs/5075730602/jobs/9117235935):
imghdrdeprecation is addressed by gh-104818However, I cannot find if
datetime.utcfromtimestampdeprecation is addressed so I cannot close this issue since the originally reported warnings are fixed.hugovk commentedon May 25, 2023
The warning is new in 3.12 and first needs fixing in Sphinx:
https://github.com/search?q=repo%3Asphinx-doc%2Fsphinx%20datetime.utcfromtimestamp&type=code
Would you like to open an issue over there? cc @AA-Turner
arhadthedev commentedon May 25, 2023
I'll do it later this day if nobody else gets ahead of me.
Btw, https://docs.python.org/3/library/datetime.html#datetime.datetime.utcfromtimestamp seems to not have the deprecation note.
hugovk commentedon May 25, 2023
Yep, the deprecation is new in 3.12, and shown here:
The issue: #103857
AA-Turner commentedon Oct 6, 2023
These have all been fixed (pending updating the Sphinx version).
A