[New-bugs-announce] [issue21343] os.path.relpath returns inconsistent types

Matt Bachmann report at bugs.python.org
Thu Apr 24 08:40:22 CEST 2014


New submission from Matt Bachmann:

I noticed an issue passing in unicode to os.path.relpath.

Specifically that in some cases when passing in unicode I would get back unicode and others I would get back a string. Below I demonstrate the issue. I also attached a patch.

Is this an issue or am I misunderstanding something. Is the patch reasonable? Totally willing to improve and i'll admit I cannot test the ntpath version.

Python 2.7.6 (default, Apr  9 2014, 11:48:52)
[GCC 4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.38)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.path.relpath(u'.', u'.')
'.'
>>> os.path.relpath(u'.', u'../')
u'bachmann'

----------
components: Library (Lib)
files: reldir.patch
keywords: patch
messages: 217119
nosy: Matt.Bachmann
priority: normal
severity: normal
status: open
title: os.path.relpath returns inconsistent types
type: behavior
versions: Python 2.7
Added file: http://bugs.python.org/file35019/reldir.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21343>
_______________________________________


More information about the New-bugs-announce mailing list