[New-bugs-announce] [issue25330] Two issues with pkgutil.get_data

Antony Lee report at bugs.python.org
Wed Oct 7 05:06:14 CEST 2015


New submission from Antony Lee:

The docs of pkgutil.get_data say "The resource argument should be in the form of a relative filename, using / as the path separator. The parent directory name .. is not allowed, and nor is a rooted name (starting with a /)."

In fact (on Python 3.5 at least):
* pkgutil.get_data("logging", "/__init__.py") works, but simply chops off the first slash, returning the contents of the stdlib's logging/__init__.py.
* pkgutil.get_data("logging", "../re.py") works, returning the contents of the stdlib's re.py.

People who actually thought about the implications of get_data/zipimport/etc. can decide whether to remove this functionality or to update the docs, I'm just reporting it.

Also, it would be nice if get_data gained a "text mode" (i.e. returning str instead of bytes and with support for universal newlines).

----------
components: Library (Lib)
messages: 252450
nosy: Antony.Lee
priority: normal
severity: normal
status: open
title: Two issues with pkgutil.get_data
versions: Python 3.6

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue25330>
_______________________________________


More information about the New-bugs-announce mailing list