This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: make doctest fails
Type: Stage: resolved
Components: Documentation Versions: Python 3.10
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: docs@python Nosy List: Arthur-Milchior, docs@python, ned.deily
Priority: normal Keywords:

Created on 2021-11-28 22:59 by Arthur-Milchior, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (3)
msg407238 - (view) Author: Arthur Milchior (Arthur-Milchior) * Date: 2021-11-28 22:59
On current main,  f87ea0350286837e9e96de03f8bfa215176c2928 , 
```
cd cpython/Doc
make doctest
```
fails. 

Due to:

Document: library/functions
---------------------------

Warning, treated as error:
**********************************************************************
File "library/functions.rst", line ?, in default
Failed example:
    list(zip(range(3), ['fee', 'fi', 'fo', 'fum'], strict=True))
Expected:
    Traceback (most recent call last):
      ...
    ValueError: zip() argument 2 is longer than argument 1
Got:
    Traceback (most recent call last):
      File "/usr/lib/python3.8/doctest.py", line 1336, in __run
        exec(compile(example.source, filename, "single",
      File "<doctest default[0]>", line 1, in <module>
        list(zip(range(3), ['fee', 'fi', 'fo', 'fum'], strict=True))
    TypeError: zip() takes no keyword arguments



This is not surprising since zip didn't take "Strict" kwarg in 3.8. The issue is that 3.10 doc is tested with Python 3.8.


If in Makefile I change Python to "Python3.10" I get a new error, but it still mention "/usr/lib/python3.8/doctest.py" so I guess for some reason it was not using 3.10 everywhere. 
I don't know make enough to have any idea how to correct this one.



By the way, is there a tool to auto-format .rst file? Initially, that was what I was trying to figure out, if I could get automatically warning when a new line is more than 80 chars long for example.
msg407239 - (view) Author: Arthur Milchior (Arthur-Milchior) * Date: 2021-11-28 23:27
I know understand one thing I missed.
I needed to do `make venv` after changing the make file to get 3.10 in virtual environment.
The issue being that this would make doc harder to create on ubuntu since 3.10 is not yet easily accessible through apt/snap.

Anyway, even when it's done, when 3.10-venv is installed on my machine and I remake venv, and I run doctest, it still fails with:

Document: library/statistics
----------------------------

Warning, treated as error:
**********************************************************************
File "library/statistics.rst", line 150, in default
Failed example:
    fmean(grades, weights)
Exception raised:
    Traceback (most recent call last):
      File "/usr/lib/python3.10/doctest.py", line 1348, in __run
        exec(compile(example.source, filename, "single",
      File "<doctest default[2]>", line 1, in <module>
        fmean(grades, weights)
    TypeError: fmean() takes 1 positional argument but 2 were given


Which comes from the fact that fmean got a new argument in 3.11 it didn't had in 3.10

So I guess the only way to actually get make doctest to work is if the virtual env uses the version of python in main. Is there anyway to do that?
msg407542 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2021-12-02 18:20
> So I guess the only way to actually get make doctest to work is if the virtual env uses the version of python in main. Is there anyway to do that?

By default, the Doc/Makefile "venv" target uses the first "python3" it finds on your shell PATH to build the venv and sphinx. Either arrange for "python3" to point at a Python of the same release family on your PATH or you can use the PYTHON= command line argument to "make venv" to specify the path to the interpreter, for example:

cd cpython
./configure && make
cd Doc
make clean venv doctest PYTHON=../python
  [...]
  Doctest summary
  ===============
   2388 tests
      0 failures in tests
      0 failures in setup code
      0 failures in cleanup code
  build succeeded.
  [...]
History
Date User Action Args
2022-04-11 14:59:52adminsetgithub: 90078
2021-12-02 18:20:31ned.deilysetstatus: open -> closed

nosy: + ned.deily
messages: + msg407542

resolution: not a bug
stage: resolved
2021-11-28 23:27:06Arthur-Milchiorsetmessages: + msg407239
2021-11-28 22:59:43Arthur-Milchiorcreate