New submission from Joseph Martinot-Lagarde <contreba...@gmail.com>:
os.fspath() returns its argument if it is a str. That means that it bypasses __fspath__ for str subclasses. This is the case for the library path.py for example. This is a corner case that was discovered while trying to fix https://github.com/matplotlib/matplotlib/issues/11306 Minimal example: ``` import os class MyPath(str): def __fspath__(self): print("Returns a pure string") return str(self) os.fspath(MyPath()) # Prints nothing ``` ---------- components: Library (Lib) messages: 317666 nosy: contrebasse priority: normal severity: normal status: open title: os.fspath() bypasses __fspath__ for str subclasses type: behavior versions: Python 3.6 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue33646> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com