-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CLI: Fix error in
aiida.cmdline.utils.log.CliFormatter
(#5957)
The `CliFormatter` could raise an exception if the record message contained named parameters, but the `args` is a tuple. An example is when the `QueryBuilder` would log the prepared SQL statement, e.g.: SELECT t.pk FROM t WHERE t.pk = %(pk_1)s The `%(pk_1)s` here is indeed a named parameter, but not intended to be formatted for the log message itself, but to be kept as is. However, the log formatter does not know this and would attempt to format it with the given `args`, which would be the empty tuple. This would raise: TypeError: format requires a mapping The `CliFormatter.format` didn't account for this case. Instead of fixing it there, the class now just refers to the base `Formatter` class to format the record, which does the right thing in this case, and the `CliFormatter` simply adds the prefix to the formatted message if necessary.
- Loading branch information
Showing
2 changed files
with
25 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters