New submission from Nick Smith <ni...@fastmail.fm>:

The log_error method in refactor.RefactoringTool raises the exception:

    def log_error(self, msg, *args, **kwds):
        """Called when an error occurs."""
        raise

but every usage of it implies that it does not, e.g:

    def refactor_string(self, data, name):
        """Refactor a given input string.
        Args:
            data: a string holding the code to be refactored.
            name: a human-readable name for use in error/log messages.
        Returns:
            An AST corresponding to the refactored input stream; None if
            there were errors during the parse.
        """
        # [..]
        try:
            tree = self.driver.parse_string(data)
        except Exception as err:
            self.log_error("Can't parse %s: %s: %s",
                           name, err.__class__.__name__, err)
            return
        finally:
        # [..]

This is the only explicit conflict I found in the documentation. From looking 
at the refactor_string function, it seems it should never raise on parse 
errors. Other uses of it are followed immediately by a return.

I'd like to see log_error only log the exception and continue.

----------
components: 2to3 (2.x to 3.x conversion tool)
messages: 311507
nosy: soupytwist
priority: normal
severity: normal
status: open
title: lib2to3 log_error method behavior is inconsitent with documentation
type: behavior
versions: Python 2.7, Python 3.4, Python 3.5, Python 3.6, Python 3.7, Python 3.8

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

Reply via email to