Skip to content

Audit sets/dicts of py.path.locals #7357

@bluetech

Description

@bluetech

py.path.local has a footgun flaw: __eq__ on Windows is case-insensitive, but __hash__ returns the hash of the strpath directly, meaning a == b does not imply hash(a) == hash(b). So things like this are possible:

import sys, py
assert sys.platform == "win32"

a = py.path.local("/some/path")
b = py.path.local("/some/PATH")
assert a == b  # Passes
assert a in {b}  # Fails
assert a in {b: 'b'}  # Fails

This probably causes some subtle bugs in pytest, which uses several dicts & sets of py.path.locals. Since py is frozen, it's not possible to fix there.

I haven't checked it yet, but wanted to make a note for later.

Metadata

Metadata

Assignees

No one assigned

    Labels

    platform: windowswindows platform-specific problemstatus: needs informationreporter needs to provide more information; can be closed after 2 or more weeks of inactivitytype: bugproblem that needs to be addressed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions