Serhiy Storchaka <storchaka+cpyt...@gmail.com> added the comment:

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.

----------
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue36917>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to