Author serhiy.storchaka
Recipients Anthony Sottile, BTaskaya, Tyler Wince, dhilst, mbussonn, serhiy.storchaka
Date 2019-08-26.12:14:20
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1566821661.13.0.828783260248.issue36917@roundup.psfhosted.org>
In-reply-to
Content
Thank you for your report and discussion Anthony.

Added the default implementation of visit_Constant which calls corresponding visitor for old constant nodes. It emits a deprecation warning (PendingDeprecationWarning in 3.8 and DeprecationWarning in 3.9) as a reminder that you finally will need to implement your own visit_Constant. You can temporary ignore them.

Note that the implementation in the stdlib is not future proof (and it should not, because visit_Constant will likely be removed at the same time or before removing classes Num and Str and removing properties "n" and "s" from Constant). In long term solution you should write something like:

class V(ast.NodeVisitor):
    def _visit_string(self, node, value):
        ...

    def visit_Str(self, node):
        return self._visit_string(node, node.s)

    def visit_Constant(self, node):
        if isinstance(node.value, str):
            return self._visit_string(node, node.value)
        ...

Otherwise you can get other deprecation warnings or errors in future releases.
History
Date User Action Args
2019-08-26 12:14:21serhiy.storchakasetrecipients: + serhiy.storchaka, mbussonn, Anthony Sottile, BTaskaya, dhilst, Tyler Wince
2019-08-26 12:14:21serhiy.storchakasetmessageid: <1566821661.13.0.828783260248.issue36917@roundup.psfhosted.org>
2019-08-26 12:14:21serhiy.storchakalinkissue36917 messages
2019-08-26 12:14:20serhiy.storchakacreate