Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/silence doctest warnings #94001

Closed
ezio-melotti opened this issue Jun 19, 2022 · 7 comments
Closed

Fix/silence doctest warnings #94001

ezio-melotti opened this issue Jun 19, 2022 · 7 comments
Labels
3.11 only security fixes 3.12 bugs and security fixes 3.13 new features, bugs and security fixes pending The issue will be closed if no feedback is provided tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error

Comments

@ezio-melotti
Copy link
Member

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 imp
3.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))
@ezio-melotti ezio-melotti added type-bug An unexpected behavior, bug, or error tests Tests in the Lib/test dir 3.11 only security fixes 3.10 only security fixes 3.12 bugs and security fixes labels Jun 19, 2022
@CAM-Gerlach
Copy link
Member

The stdlib's tests use the _ignore_deprecated_imports context 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
Copy link
Member

hugovk commented Jun 26, 2022

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.

Third-party deprecation warnings in main and 3.11:

/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

Fixed in python-babel/babel#876, pending release.

Edit: ✅ Released in Babel 2.11.0!

/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

Pending issue: sphinx-doc/sphinx#10440

Edit: ✅ Released in Sphinx 6.2.0!

/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.

PR pending merge: certifi/python-certifi#193

Edit: ✅ Merged via certifi/python-certifi#199 and released in Certifi 2022.06.15.1!

@arhadthedev
Copy link
Member

Current status (from https://github.com/python/cpython/actions/runs/5075730602/jobs/9117235935):

Run xvfb-run make -C Doc/ PYTHON=../python SPHINXERRORHANDLING="-W --keep-going" doctest
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  -W --keep-going . build/doctest 
Running Sphinx v[4](https://github.com/python/cpython/actions/runs/5075730602/jobs/9117235935#step:9:5).[5](https://github.com/python/cpython/actions/runs/5075730602/jobs/9117235935#step:9:6).0
/home/runner/work/cpython/cpython/Doc/venv/lib/python3.13/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.13/site-packages/sphinx/builders/gettext.py:1[6](https://github.com/python/cpython/actions/runs/5075730602/jobs/9117235935#step:9:7)4: DeprecationWarning: datetime.utcfromtimestamp() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.fromtimestamp(timestamp, datetime.UTC).
  datetime.utcfromtimestamp(timestamp)

imghdr deprecation is addressed by gh-104818

However, I cannot find if datetime.utcfromtimestamp deprecation is addressed so I cannot close this issue since the originally reported warnings are fixed.

@arhadthedev arhadthedev added the pending The issue will be closed if no feedback is provided label May 25, 2023
@hugovk
Copy link
Member

hugovk commented May 25, 2023

However, I cannot find if datetime.utcfromtimestamp deprecation is addressed so I cannot close this issue since the originally reported warnings are fixed.

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
Copy link
Member

Would you like to open an issue over there?

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.

@AA-Turner AA-Turner added 3.13 new features, bugs and security fixes and removed 3.10 only security fixes labels Oct 6, 2023
@AA-Turner
Copy link
Member

These have all been fixed (pending updating the Sphinx version).

A

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.11 only security fixes 3.12 bugs and security fixes 3.13 new features, bugs and security fixes pending The issue will be closed if no feedback is provided tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

5 participants