What types should be accepted as bytes path?

For now os.path is strict and accepts only bytes and bytes subclasses (even bytearray is not accepted) as bytes path. This is enough for working with low-level Posix paths and supporting backward compatibility.

On other hand, most os functions is too permissive since 3.3 and accept any type that supports the buffer protocol as bytes path. Accepted even such meaningless objects as array('h').

Some functions (zipimport.zipimporter() in 3.x, _imp.load_dynamic() in 3.3+, builtin compile() etc in 3.4) accept even arbitrary iterables, e.g. [116, 101, 115, 116] (see http://bugs.python.org/issue26754).

I think we should accept only bytes (and subclasses). Even bytearray is less acceptable since it is mutable and can't be used as a key in caches.

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to