summaryrefslogtreecommitdiff
path: root/astroid/rebuilder.py
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-06-18 11:11:57 +0200
committerClaudiu Popa <pcmanticore@gmail.com>2019-07-06 19:18:30 +0300
commit4edf7190c9fdd2c749c60eb649e755ec19e5e9c8 (patch)
tree0871f241d944c525fe8d26397ea0cd3e049f181f /astroid/rebuilder.py
parent081f7d32783723482a865f1b1593e731a23f68d9 (diff)
downloadastroid-git-4edf7190c9fdd2c749c60eb649e755ec19e5e9c8.tar.gz
Fix finding of docstring under python3.8
It is stored as a Constant, not a Str, so we the the value a bit differently. Fixes one test failure in https://github.com/gristlabs/asttokens/issues/28.
Diffstat (limited to 'astroid/rebuilder.py')
-rw-r--r--astroid/rebuilder.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/astroid/rebuilder.py b/astroid/rebuilder.py
index 51fa0ab8..3181eaba 100644
--- a/astroid/rebuilder.py
+++ b/astroid/rebuilder.py
@@ -133,9 +133,11 @@ class TreeRebuilder:
if (
node.body
and isinstance(node.body[0], self._parser_module.Expr)
- and isinstance(node.body[0].value, self._parser_module.Str)
+ and isinstance(node.body[0].value,
+ self._parser_module.Constant if PY38 else self._parser_module.Str)
):
- doc = node.body[0].value.s
+ value = node.body[0].value
+ doc = value.value if PY38 else value.s
node.body = node.body[1:]
return node, doc
except IndexError: