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
bpo-28249: fix lineno
location for empty DocTest
instances
#30498
Conversation
Misc/NEWS.d/next/Library/2022-01-09-14-23-00.bpo-28249.4dzB80.rst
Outdated
Show resolved
Hide resolved
This PR is stale because it has been open for 30 days with no activity. |
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
I rebased and resolved a conflict with |
…nGH-30498) Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> Co-authored-by: Łukasz Langa <lukasz@langa.pl> (cherry picked from commit 8db2b3b) Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Sorry, @sobolevn and @ambv, I could not cleanly backport this to |
Sorry @sobolevn and @ambv, I had trouble checking out the |
GH-92978 is a backport of this pull request to the 3.11 branch. |
…pythonGH-30498) Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> Co-authored-by: Łukasz Langa <lukasz@langa.pl> (cherry picked from commit 8db2b3b) Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
GH-92981 is a backport of this pull request to the 3.10 branch. |
This patch fixes
lineno
forDocTest
instances for objects that don't have__doc__
attribute.In the original issue this was used as an example:
Before this patch,
doctest.DocTestFinder(exclude_empty=False).find(example_module)
was showing:Notice that
lineno
was5
forexample
andexample.a
. Which is clearly wrong, becauseexample.b
is on the 5th line. But,example.c
hadlineno=None
.DocTest
docs clearly state:So, now
lineno
is set toNone
when__doc__
cannot be found. Now, the result for ourexample
module will be:Now, everything looks correct.
https://bugs.python.org/issue28249
CC @corona10 as my mentor🙂