Skip to content

Conversation

myint
Copy link
Member

@myint myint commented May 12, 2017

No description provided.

@myint myint merged commit 074c21d into master May 12, 2017
@myint myint deleted the allow-failure-in-nightly-python branch May 12, 2017 17:14
@myint
Copy link
Member Author

myint commented May 14, 2017

It looks like the CPython 3.7 failure is related to a change in the AST. The docstring is no longer in node.body.

python/cpython#46

We can mostly replace our getDocstring(node.body[0]) call with node.docstring. But I'm not sure how to get the line number of the docstring anymore. node.lineno is close, but not quite the line number of the docstring.

(docstring, node_lineno) = self.getDocstring(node.body[0])

diff --git a/pyflakes/checker.py b/pyflakes/checker.py
index 382574e..2c19533 100644
--- a/pyflakes/checker.py
+++ b/pyflakes/checker.py
@@ -870,7 +870,11 @@ class Checker(object):

     def handleDoctests(self, node):
         try:
-            (docstring, node_lineno) = self.getDocstring(node.body[0])
+            if hasattr(node, 'docstring'):
+                docstring = node.docstring
+                node_lineno = ???  # TODO
+            else:
+                (docstring, node_lineno) = self.getDocstring(node.body[0])
             examples = docstring and self._getDoctestExamples(docstring)
         except (ValueError, IndexError):
             # e.g. line 6 of the docstring for <string> has inconsistent

@myint
Copy link
Member Author

myint commented May 14, 2017

@methane After the change in python/cpython#46, is there still a simple way to get the line number of a docstring? It used to be something like:

node.body[0].value.lineno

Thanks

@myint myint mentioned this pull request May 28, 2017
myint added a commit that referenced this pull request May 29, 2017
myint added a commit that referenced this pull request Jun 6, 2017
* Ignore temporary files

* Support Python 3.7

This fixes #271.

* Re-enable nightly in Travis CI

This relates to #90.

* Undo 821a069
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants