[issue19997] imghdr.what doesn't accept bytes paths

2014-08-21 Thread Claudiu Popa
Claudiu Popa added the comment: Right, I've read the thread you posted and I agree. My use cases aren't strong enough and it's enough for me to call os.fsdecode. -- resolution: -> wont fix stage: patch review -> resolved status: pending -> closed __

[issue19997] imghdr.what doesn't accept bytes paths

2014-08-21 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: See also a discussion at Python-Dev: http://comments.gmane.org/gmane.comp.python.devel/149048 Looks as there are no need to add bytes path support in such high-level API. In any case you can call os.fsdecode() on path argument. -- status: open -> pen

[issue19997] imghdr.what doesn't accept bytes paths

2014-06-02 Thread Claudiu.Popa
Claudiu.Popa added the comment: There are other modules with support for bytes filenames in their API: bz2 codecs gzip lzma pipes.Template tarfile tokenize fileinput filecmp sndhdr c

[issue19997] imghdr.what doesn't accept bytes paths

2014-02-22 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I'm not sure imghdr.what() should support bytes path. The open() builtin, most os and os.path functions support string and bytes paths, but many other modules (including pathlib) support only string paths. -- nosy: +pitrou __

[issue19997] imghdr.what doesn't accept bytes paths

2014-02-22 Thread Antoine Pitrou
Changes by Antoine Pitrou : -- nosy: +serhiy.storchaka stage: -> patch review ___ Python tracker ___ ___ Python-bugs-list mailing lis

[issue19997] imghdr.what doesn't accept bytes paths

2014-02-22 Thread Claudiu.Popa
Claudiu.Popa added the comment: Patch updated. It removes the check added in http://hg.python.org/cpython/rev/94813eab5a58 and simplifies the test for bytes file path. -- Added file: http://bugs.python.org/file34181/imghdr_bytes_2.patch ___ Python t

[issue19997] imghdr.what doesn't accept bytes paths

2014-01-19 Thread Claudiu.Popa
Claudiu.Popa added the comment: Updated patch to use real image files from issue #19990. -- Added file: http://bugs.python.org/file33553/imghdr_bytes.patch ___ Python tracker ___

[issue19997] imghdr.what doesn't accept bytes paths

2013-12-19 Thread STINNER Victor
Changes by STINNER Victor : -- dependencies: +Add unittests for imghdr module ___ Python tracker ___ ___ Python-bugs-list mailing list

[issue19997] imghdr.what doesn't accept bytes paths

2013-12-18 Thread Claudiu.Popa
Claudiu.Popa added the comment: Added the new version. > (You may use a valid sound file of the Python suite test instead of > generating an invalid sounf file.) Oh, that's sndhdr, currently imghdr doesn't have valid image files in the Python suite test (there is another issue for adding a te

[issue19997] imghdr.what doesn't accept bytes paths

2013-12-18 Thread Claudiu.Popa
Claudiu.Popa added the comment: Hi, Victor! The second patch does use os.fsencode. I'll update the first one with this change. -- ___ Python tracker ___

[issue19997] imghdr.what doesn't accept bytes paths

2013-12-18 Thread STINNER Victor
STINNER Victor added the comment: imghdr_bytes.patch should use os.fsencode() to encode the filename, not filename.encode(). (You may use a valid sound file of the Python suite test instead of generating an invalid sounf file.) imghdr_files.patch looks overkill. I don't think that it's useful

[issue19997] imghdr.what doesn't accept bytes paths

2013-12-17 Thread Claudiu.Popa
Claudiu.Popa added the comment: Thanks, Vajrasky, I forgot about the fact that open can open file descriptors. Here's a patch which fixes this, also adds a test for BytesIO and uses os.fsencode instead of .encode(). -- Added file: http://bugs.python.org/file33174/imghdr_files.patch __

[issue19997] imghdr.what doesn't accept bytes paths

2013-12-16 Thread Vajrasky Kok
Vajrasky Kok added the comment: Why limit to str and bytes. Open can accept integer as well. I am asking not suggesting. >>> with open('/tmp/cutecat.txt', 'wb') as f: ... f.write(b'cutecat') ... 7 >>> a = open('/tmp/cutecat.txt') >>> a.fileno() 3 >>> b = open(3) >>> b.read() 'cutecat' -

[issue19997] imghdr.what doesn't accept bytes paths

2013-12-16 Thread Claudiu.Popa
New submission from Claudiu.Popa: imghdr.what check explicitly for string path, while `open` happily accepts bytes paths, as seen below: >>> x b'\xc2\xba' >>> imghdr.what(x) Traceback (most recent call last): File "", line 1, in File "/tank/libs/cpython/Lib/imghdr.py", line 15, in what