GH-84783: Make the slice object hashable by furkanonder · Pull Request #101264 · python/cpython (original) (raw)

@furkanonder

I think I understand now why test_doctests() is failing.

On my system, if I clone main, build it normally (non-debug), and compute len(tests) (see previous comment), I get 843.

Now, if I clone your branch, build it normally (non-debug), I get 844 instead. The extra entry to tests is <DocTest builtins.slice.__hash__ from builtins:None (no examples)>, which isn't an element of tests on main.

Now, running the tests (on your branch) with non-debug mode succeeds on my system.

Once we build with --with-pydebug, however, this adds an additional entry to tests, namely, <DocTest builtins.set.test_c_api from builtins:None (no examples)> (whether on your branch or main), making the number on your branch 845, which makes

>>> 825 < len(tests) < 845 # approximate number of objects with docstrings

fail.

So, I think what needs to be done now is for you to modify that line in test_doctest.py, say, to

830 < len(tests) < 850

I have verified that test_doctests() passes after this change (both on non-debug and debug builds).

For reference:

import builtins, doctest tests = doctest.DocTestFinder().find(builtins)