[New-bugs-announce] [issue38878] os.PathLike subclasshook causes subclass checks true on abstract implementation

Bar Harel report at bugs.python.org
Thu Nov 21 10:00:21 EST 2019


New submission from Bar Harel <bzvi7919 at gmail.com>:

Quick and small fix.

os.PathLike.__subclasshook__ does not check if cls is PathLike as abstract classes should.

This in turn causes this bug:

    class A(PathLike):
        pass

    class B:
        def __fspath__(self):
            pass

    assert issubclass(B, A)

I will fix the bug later today and push a patch over to python/cpython on GitHub.

----------
components: Library (Lib)
messages: 357174
nosy: bar.harel
priority: normal
severity: normal
status: open
title: os.PathLike subclasshook causes subclass checks true on abstract implementation
type: behavior
versions: Python 3.6, Python 3.7, Python 3.8, Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue38878>
_______________________________________


More information about the New-bugs-announce mailing list