Closed AraHaan closed 2 months ago
It seems it happens when doing that import because discord\ext folder does not have an empty __init__.py
and when building the zip does not result in an empty __init__.pyc
file to tell the importer to import it all properly.
It seems a bug in official zipimport.py
module, _is_dir
function only check existing entries, the dir path were not be compressed in as an entry in most cases.
So, basically contribute a patch that checks for directories inside of that directory that might have python files ()check nested directories) in the case that it does not find any python files directly in the directory that it is checking? Sounds like a good patch to me.
In my way, I may put some fake directory entries like this:
# Directory entries may be not included which can cause namespace import fail,
# add them here.
def _fix_up_directory(files):
for path in tuple(files.keys()):
dirpath = _path_dirname(path) + '\\'
if dirpath not in files:
files[dirpath] = (_path_dirname(files[path][0]), 0, 0, 0, 0, 0, 0, 0)
def _read_directory_fixed(archive):
return _fix_up_directory(_read_directory(archive))
After bug fixed, here will add backports for older versions if official does not.
I have a python file that does something along the lines of
from discord.ext.commands import Bot
And it seems that with this on that zip file the import is busted and it becomes unable to find that module.