classification
Title: zipimport loader.get_data() requires absolute zip file path
Type: Stage: resolved
Components: Versions: Python 3.8
process
Status: closed Resolution: works for me
Dependencies: Superseder:
Assigned To: Nosy List: barry, nnja, serhiy.storchaka
Priority: normal Keywords:

Created on 2018-02-18 02:49 by barry, last changed 2019-01-17 18:40 by nnja. This issue is now closed.

Messages (3)
msg312296 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2018-02-18 02:49
Over in https://gitlab.com/python-devs/importlib_resources/issues/48 we have a report of a FileNotFoundError when trying to read a resource from a zip file.  Upon further debugging, I found that zipimport's loader.get_data() raises an unexpected OSError.  Interestingly, if the path to the zip file is absolute, everything works as expected, but if the path is relative, then it fails.

There's probably a missing abspath() in there somewhere, but as zipimport is written in C, I really didn't spend much time digging around in gdb.
msg325727 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-09-19 07:36
zipimport has been rewritten in pure Python (issue25711).
msg333893 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2019-01-17 18:39
I believe this bug does not affect Python 3.8:

(Using a Python 3.8 virtualenv):

% python demo.pyz 
Reading: resource.txt
Length: 19
% python `pwd`/demo.pyz 
Reading: resource.txt
Length: 19

I think it's too risky (and too much work, given it would have to be ported to the C implementation of zipimport) to change this in earlier Pythons.  So, closing.
History
Date User Action Args
2019-01-17 18:40:01nnjasetnosy: + nnja
2019-01-17 18:39:23barrysetstatus: open -> closed
versions: - Python 3.6, Python 3.7
messages: + msg333893

resolution: works for me
stage: resolved
2018-09-19 07:36:02serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg325727
2018-02-18 02:49:21barrycreate