Make pathlib extensible

Q: What should pathlib.PathBase.pathmod be set to? This attribute controls basic path syntax:

  • Whether forward or backward slashes are used as separators
  • Whether drives are supported
  • Whether path comparisons are case-sensitive

Other classes have it set as follows:

Note:

  • os.path evaluates to posixpath or ntpath at runtime, depending on whether you’re on Windows
  • PurePath, PathBase and Path can’t be directly instantiated, but they can be subclassed.

In favour of os.path: it would match the superclass (PurePath) and subclass (Path), which seems easier to explain/justify.

In favour of posixpath: implementations of PathBase other than Path generally won’t change the path syntax based on the host OS. For example, an S3Path class would consistently use POSIX syntax (forward slashes, no support for drive letters, etc) even on Windows. Unwary devs may develop entirely on Mac or Linux, without even considering that their PathBase subclass will behave differently on Windows.

Thoughts?