-
-
Notifications
You must be signed in to change notification settings - Fork 30.7k
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
doctest test finder doesnt find line numbers of properties #61648
Comments
examples that are found on a property dont detect the line number class example(object):
@property
def me(self):
"""
>>> 1/0
"""
pass |
@ronny can you provide a patch for this? |
this is my first contribution to Python core so I really have no idea how to do this, but I have found a solution (works in Py3.4, 2.7): in doctest.py after line 1087 ("lineno = getattr(obj, 'co_firstlineno', None)-1") add these lines:
I can try to make a patch file for this, but just want to be sure I'm on the right track for contributing first. I know how to do a Git pull, but not hg/patch. (p.s., I think the current code "lineno = getattr(obj, 'co_firstlineno', None)-1" has an error; if the getattr does not find 'co_firstlineno', it will return None and then subtract 1 from None which is a TypeError). |
I took the ideas from @Michael.Cuthbert and wrote a proper test. It's my first patch so I hope everything's fine with it. If not I'm happy for feedback :) |
The test looks great to me. Does anyone on nosy know the proper way to request a patch review? |
Left a comment on Rietveld. I don't have time right now to check the test, but I suspect you tested it before submitting the patch, so it should probably be fine. |
Yes, I've tested it. |
looks like we're stuck on a style change (backslash to parens; ironic: I chose backslash to match surrounding code; I never use them myself). tuxtimo - could you fix this? (or I'll do once the move to github is done). Thanks! |
Here's a rather obscure bug that I was able to catch before we put this into action: doctests inside the __doc__ for namedtuples (and perhaps all namedtuples?) are instances of property, have .fget, but do not have .fget.__code__. Thus one more check is needed:
|
just poking to see if this patch is worth trying to get into 3.7 |
A pull request has been in for about a month -- is it possible to review or merge or comment? Thanks! |
The PR appears to need a better test according to #3419 (comment). |
The code I contributed to 3.7 is still, I believe, the best path forward. Based on my experiences trying to contribute to cpython, I will not be continuing on this issue. It can be closed. |
The linked PR (#3419) seems to have been closed with no discussion, I'm reopening. A |
…GH-113161) (cherry picked from commit 8f8f0f9) Co-authored-by: Serhiy Storchaka <[email protected]>
…GH-113161) (cherry picked from commit 8f8f0f9) Co-authored-by: Serhiy Storchaka <[email protected]>
…3161) (GH-113165) (cherry picked from commit 8f8f0f9) Co-authored-by: Serhiy Storchaka <[email protected]>
…3161) (GH-113164) (cherry picked from commit 8f8f0f9) Co-authored-by: Serhiy Storchaka <[email protected]>
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
Linked PRs
The text was updated successfully, but these errors were encountered: