Check that all path handling is compliant w/ pep-0519 (Path-like, str, bytes handling)
The current code base has a mixed use of str(), .encode and .decode that seem at times inconsistent.
Paths are created at times adding strings or formatting them.
Some conversions are not needed, str() over bytes causes wrong representations, mixing types can cause errors.
Use of functions like
os.path.join(path, *paths) # (path-like, *path-like) -> str
or strings (str, unicode strings) should be encouraged
The code should be inspected (file opening, ...)
Here a specification of path-like and path handling
These posts talk about possible errors (but are not completely useful):