>> Charles ☕ Stanhope:
“I'm still puzzling over why that is a desirable default behavior for a function called join(). I'm sure the answer is in a mailing list archive or PEP.”
I found this email from 2012, discussing PEP 428:
“>> What's the use case for this behavior?
>>
>> I'd much rather if joining an absolute path to a relative one fail and
>> reveal the potential bug....
>>
>> >>> os.unlink(Path('myproj') / Path('/lib'))
>> Traceback (most recent call last):
>> File "", line 1, in
>> TypeError: absolute path can't be appended to a relative path
>
> In all honesty I followed os.path.join's behaviour here. I agree a
> ValueError (not TypeError) would be sensible too.
Please no -- this is a very important use case (for os.path.join, at least):
resolving a path from config/user/command line that can be given either absolute
or relative to a certain directory.
Right now it's as simple as join(default, path), and i'd prefer to keep this.
There is no bug here, it's working as designed. ”
https://mail.python.org/pipermail/python-ideas/2012-October/016474.html