[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 - pending

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



[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

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



[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
configparser

Also, given the fact that sndhdr supports them and its purpose is similar with 
imghdr, it would be a surprise
for a beginner to find out that imghdr.what(bimg) is not working, while 
sndhdr.what(bsnd) works.

--

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



[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 tracker rep...@bugs.python.org
http://bugs.python.org/issue19997
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2014-02-22 Thread Antoine Pitrou

Changes by Antoine Pitrou pit...@free.fr:


--
nosy: +serhiy.storchaka
stage:  - patch review

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



[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

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



[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 rep...@bugs.python.org
http://bugs.python.org/issue19997
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



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

2013-12-19 Thread STINNER Victor

Changes by STINNER Victor victor.stin...@gmail.com:


--
dependencies: +Add unittests for imghdr module

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



[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 to support 
integer file descriptor. Being able to pass an open file is enough. 
imghdr_bytes.patch is fine.

--
nosy: +haypo

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



[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 rep...@bugs.python.org
http://bugs.python.org/issue19997
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[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 test file for this 
module). If it's required, sure, I'll add a few.

--
Added file: http://bugs.python.org/file33195/imghdr_files_2.patch

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



[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

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



[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 stdin, line 1, in module
  File /tank/libs/cpython/Lib/imghdr.py, line 15, in what
location = file.tell()
AttributeError: 'bytes' object has no attribute 'tell'
 open(x)
_io.TextIOWrapper name=b'\xc2\xba' mode='r' encoding='UTF-8'

A reason why this should be supported can be found in this message: 
http://bugs.python.org/msg191691.
The following patch fixes this. Also, it depends on issue19990 (where 
test_imghdr.py was added).

--
components: Library (Lib)
files: imghdr_bytes.patch
keywords: patch
messages: 206299
nosy: Claudiu.Popa
priority: normal
severity: normal
status: open
title: imghdr.what doesn't accept bytes paths
type: behavior
versions: Python 3.5
Added file: http://bugs.python.org/file33164/imghdr_bytes.patch

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



[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'

--
nosy: +vajrasky

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