Serhiy Storchaka added the comment:
OK. I say the original issue is not a bug.
--
resolution: - not a bug
stage: - resolved
status: open - closed
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21343
Serhiy Storchaka added the comment:
Why you should check the type? There is no difference between '.' and u'.'.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21343
___
Matt Bachmann added the comment:
There is a difference! '.' is a bytes string and u'.' is a unicode one!
I found this problem because I work on a project that supports both python2 and
python3.
In python3 I pass in unicode I get back unicode. In python2.7 I pass in unicode
and I get back a
Matt Bachmann added the comment:
Perhaps this is the bug I should be filing but here is why this comes up for
me.
I get different output from this function if I pass in two types.
On my machine:
os.path.relpath(u'test_srcl.txt', u'.') returns u'test_src.txt'
os.path.relpath(u'test_srcl.txt',
Serhiy Storchaka added the comment:
In Python 2 str is coerced to unicode, so most functions should return the same
(or compatible) result for str and unicode argument if it contains only 7-bit
ASCII characters. Of course there are several obvious exceptions, such as
type() or repr(). And
Matt Bachmann added the comment:
Looking into the project im working on I discovered why relpath was acting
strangely.
It is because the project mocks get_cwd but not get_cwdu. Your request helped
me track that down :-)
So that is not an issue. However, the issue described in the original
Serhiy Storchaka added the comment:
I think this is not a bug and shouldn't be fixed in 2.7.
--
nosy: +serhiy.storchaka
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21343
___
Matt Bachmann added the comment:
Can you help me understand why not?
If I give it two unicode strings it sometimes gives me back a unicode and
sometimes gives me back a string.
In python3 this does what I expect.
In python27 I now have to check the type I get back because I cannot be sure
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