New submission from Nick Smith <>:

The log_error method in refactor.RefactoringTool raises the exception:

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

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

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

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 <>
Python-bugs-list mailing list

Reply via email to