[Python-Dev] Pathlib enhancements - acceptable inputs and outputs for __fspath__ and os.fspath()

Ethan Furman ethan at stoneleaf.us
Mon Apr 18 18:30:38 EDT 2016


On 04/18/2016 12:26 PM, Stephen J. Turnbull wrote:

> I haven't looked at Antipathy, but I would guess from Ethan's
> promotion of bytes paths and concern with efficiency that "bytes
> antipaths" do *not* "go through" str to get to bytes, they already are
> bytes (in the sense of class inheritance).

Couple points:

- Correct: if you create an antipathy.Path with bytes, you get a
   bytes path (bPath); if you create an antipathy.Path with str
   you get a str path (uPath)

- if you mix a bPath with a uPath, or bytes with a uPath, or str with
   a bPath -- an exception is raised (conversions are *not* implicit (on
   3.0, at least -- on 2.x you can activate that behavior if you want it)

- my concern with supporting bytes is primarily for the sake of the
   stdlib, and secondarily for anyone who needs to work with bytes; it
   really has no effect on my library (since antipathy uses subclasses
   of bytes/str)

--
~Ethan~


More information about the Python-Dev mailing list