Author javawizard
Recipients javawizard, pitrou
Date 2013-12-18.06:10:08
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
pathlib.Path.relative_to() blows up when given a path that's not an ancestor of the path on which relative_to is being called:

>>> pathlib.Path("/usr/bin").relative_to("/etc")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "", line 822, in relative_to
    .format(str(self), str(formatted)))
ValueError: '/usr/bin' does not start with '/etc'

The equivalent with posixpath.relpath (or ntpath.relpath) works just fine:

>>> posixpath.relpath("/usr/bin", "/etc")

It'd be nice if Path.relative_to supported this type of usage.
Date User Action Args
2013-12-18 06:10:11javawizardsetrecipients: + javawizard, pitrou
2013-12-18 06:10:11javawizardsetmessageid: <>
2013-12-18 06:10:10javawizardlinkissue20012 messages
2013-12-18 06:10:08javawizardcreate