[issue21127] Path objects cannot be constructed from str subclasses

2014-04-22 Thread Roundup Robot

Roundup Robot added the comment:

New changeset c24cbd9bd63b by Antoine Pitrou in branch '3.4':
Issue #21127: Path objects can now be instantiated from str subclass instances 
(such as numpy.str_).
http://hg.python.org/cpython/rev/c24cbd9bd63b

New changeset aad6d6b819ed by Antoine Pitrou in branch 'default':
Issue #21127: Path objects can now be instantiated from str subclass instances 
(such as numpy.str_).
http://hg.python.org/cpython/rev/aad6d6b819ed

--
nosy: +python-dev

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21127
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21127] Path objects cannot be constructed from str subclasses

2014-04-22 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Ok, I've committed a patch (to 3.4 and 3.5) that force-casts to str.
Thank you for reporting this bug!

--
resolution:  - fixed
stage:  - resolved
status: open - closed
type:  - behavior
versions: +Python 3.4

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21127
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21127] Path objects cannot be constructed from str subclasses

2014-04-11 Thread Antony Lee

Antony Lee added the comment:

I am loading some structure from a MATLAB binary file using scipy.io.loadmat.  
This structure contains (in particular) paths (written as bytestrings) to other 
files which end up being loaded as numpy.str_ objects.

In fact, just trying to store and retrieve strings from numpy arrays wraps them 
in numpy.str_:

 import numpy
 type(numpy.array([foo])[0])
class 'numpy.str_'

... and now trying to construct a Path from that will crash.

I agree, though, that force-casting str subclasses in the constructor may avoid 
other issues.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21127
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21127] Path objects cannot be constructed from str subclasses

2014-04-10 Thread Antoine Pitrou

Antoine Pitrou added the comment:

I'm curious: what is the use case for str subclasses in Path objects?
If this is to be supported, I think I'd rather force-cast to str rather than 
accept arbitrary subclasses.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21127
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21127] Path objects cannot be constructed from str subclasses

2014-04-08 Thread Antony Lee

Antony Lee added the comment:

The attached patch should fix the issue.

--
keywords: +patch
Added file: http://bugs.python.org/file34759/pathlib.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21127
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21127] Path objects cannot be constructed from str subclasses

2014-04-01 Thread Antony Lee

New submission from Antony Lee:

Trying to construct a Path object from a str subclass, e.g.

class S(str): pass
Path(S(foo))

fails because the subclass cannot be interned.  I think that the interning 
should simply be removed for non-exactly-str arguments (it is only here for 
performance reasons, right?), or at least the error should be more explicit 
(note, in particular, that there is no error if one tries 'Path(S(foo/bar))' 
instead, which only confuses the matter more).

In practice, I found out this via numpy, which provides its own str subclass, 
numpy.str_.

--
components: Library (Lib)
messages: 215342
nosy: Antony.Lee
priority: normal
severity: normal
status: open
title: Path objects cannot be constructed from str subclasses
versions: Python 3.5

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21127
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21127] Path objects cannot be constructed from str subclasses

2014-04-01 Thread Ned Deily

Changes by Ned Deily n...@acm.org:


--
nosy: +pitrou

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21127
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com