Open
Description
If you try to use rootpy in Python 3.8, this is what happens:
>>> import rootpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/gscratch/stf/masonlp/conda/envs/root/lib/python3.8/site-packages/rootpy/__init__.py", line 29, in <module>
from .logger import log
File "/gscratch/stf/masonlp/conda/envs/root/lib/python3.8/site-packages/ROOT.py", line 533, in _importhook
return _orig_ihook( name, *args, **kwds )
File "/gscratch/stf/masonlp/conda/envs/root/lib/python3.8/site-packages/rootpy/logger/__init__.py", line 111, in <module>
handler.setFormatter(CustomColoredFormatter())
File "/gscratch/stf/masonlp/conda/envs/root/lib/python3.8/site-packages/rootpy/logger/formatter.py", line 51, in __init__
CustomFormatter.__init__(self, fmt, datefmt)
File "/gscratch/stf/masonlp/conda/envs/root/lib/python3.8/site-packages/rootpy/logger/formatter.py", line 40, in __init__
logging.Formatter.__init__(self, fmt, datefmt)
File "/gscratch/stf/masonlp/conda/envs/root/lib/python3.8/logging/__init__.py", line 576, in __init__
self._style.validate()
File "/gscratch/stf/masonlp/conda/envs/root/lib/python3.8/logging/__init__.py", line 429, in validate
raise ValueError("Invalid format '%s' for '%s' style" % (self._fmt, self.default_format[0]))
ValueError: Invalid format '{color}{levelname}:{name}] {message}' for '%' style
This is because CustomFormatter
calls logging.Formatter.__init__()
with a .format()
style string, but the style
for Formatter
defaults to '%'
(see https://docs.python.org/3/library/logging.html#logging.Formatter). format()
is overridden for the class, which is why everything works in Python versions before 3.8, but 3.8 added a validate=True
parameter, which verifies that the given string actually follows the expected format. Otherwise it raises an error like above.
Metadata
Metadata
Assignees
Labels
No labels