[New-bugs-announce] [issue32750] lib2to3 log_error method behavior is inconsitent with documentation
Nick Smith
report at bugs.python.org
Fri Feb 2 13:37:47 EST 2018
New submission from Nick Smith <nicks at 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 <report at bugs.python.org>
<https://bugs.python.org/issue32750>
_______________________________________
More information about the New-bugs-announce
mailing list