Repository navigation
v0.9.2
Fixed
MemPath.open("w")on an existing directory raised nothing and destroyed
the tree._open()assigned over whatever was already at the name, so
MemPath("dir").write_text(...)replaced a directory and everything under
it with a file — silently, in the class the docs present as the reference
exemplar for extending this library, and the class used as a mock
filesystem in tests. It now raisesIsADirectoryError, aspathlibdoes.
The same guard covers the virtual root for every mode, which used to grow a
bogus""key in the backend on"w"/"a".- A
MemPathrouted through a file raisedTypeError.
_parent_container()walked ancestors withpath not in parent, which on a
bytearrayancestor evaluates"seg" not in bytearray. ThatTypeError
sails past theOSErrorguard inStat._st_mode(), so even
MemPath("file.txt/sub").exists()crashed instead of returningFalse—
a routine shape in glob/walk and inmkdir(parents=True). It now raises
NotADirectoryErrornaming the offending ancestor. Pathnamehad no__eq__/__hash__, so subclasses compared by
identity. Every pure subclass that didn't hand-write equality — including
MemPath, and any downstream class subclassingPathdirectly — was
unusable as a dict key or set member, andis_relative_to()(which decides
via==against freshly built parents) always returnedFalsewithout
raising. There is now a default keyed on
(type(self), tuple(self.segments)).LocalPath,PosixPathnameand
WindowsPathnameare unaffected —pathlib.PurePathprecedesPathnamein
their MRO and keeps its own equality — as isUri, which defines one.is_relative_to()normalized astrargument by joining it onto
self.Pathnameusedcls(self, other)andUriused
Uri(self, _ROOT, other), soUri("a/b").is_relative_to("a")compared
against"a/b/a"/"/a"and answeredFalsewhile
Uri("a/b").is_relative_to(Uri("a"))answeredTrue— the str and object
forms of the same call disagreed. Both now parseotherstandalone, as
CPython does. The generic side usesself.with_segments(other)so a
subclass's per-instance state (MemPath's backend) survives the
normalization.Uri("http://h/a/b").is_relative_to("/a")is stillTrue.LocalPath.chown()leakedAttributeError/LookupErroron Windows.
shutil.chownexists there whileos.chowndoes not, so an int id raised
AttributeErrorand a name raised a misleadingLookupError: no such user
(with nopwdmodule, every name misses whether or not the user exists).
It now raisesNotImplementedError, whichdocs/divergences.mdalready
promised and which every other unsupported capability here raises. The
all-unchanged no-op still succeeds.
Full Changelog: v0.9.1...v0.9.2