drop old Python: rm python 2 leftovers in library.FileOperationError.__str__

This commit is contained in:
wisp3rwind 2022-06-14 22:17:41 +02:00
parent 632698680f
commit 5cdb0c5c5c

View file

@ -300,34 +300,26 @@ class FileOperationError(Exception):
self.path = path
self.reason = reason
def text(self):
def __str__(self):
"""Get a string representing the error.
Describe both the underlying reason and the file path
in question.
Describe both the underlying reason and the file path in question.
"""
return '{}: {}'.format(
util.displayable_path(self.path),
str(self.reason)
)
# define __str__ as text to avoid infinite loop on super() calls
# with @six.python_2_unicode_compatible
__str__ = text
return f"{util.displayable_path(self.path)}: {self.reason}"
class ReadError(FileOperationError):
"""An error while reading a file (i.e. in `Item.read`)."""
def __str__(self):
return 'error reading ' + super().text()
return 'error reading ' + str(super())
class WriteError(FileOperationError):
"""An error while writing a file (i.e. in `Item.write`)."""
def __str__(self):
return 'error writing ' + super().text()
return 'error writing ' + str(super())
# Item and Album model classes.