33import asyncweb
44import io
55import re
6- from urllib .parse import urlparse , unquote
6+ import posixpath
7+ from urllib .parse import urlparse
78import _frozen_importlib as _bootstrap
89import _microdistlib
910
@@ -74,7 +75,7 @@ async def _load_info_pypi(pkg):
7475 try :
7576 dl = next (dl for dl in ver_downloads if dl ["packagetype" ] == "bdist_wheel" )
7677 except StopIteration :
77- raise ValueError (f"no wheel available for package { Name !r} { ver } " )
78+ raise ValueError (f"no wheel available for package { name !r} { ver } " )
7879 return (
7980 name ,
8081 dl ["filename" ],
@@ -124,11 +125,11 @@ def get_source(cls, fullname):
124125
125126 @classmethod
126127 def _get_source (cls , spec ):
127- origin = spec .origin
128- if not origin or not origin . startswith ( "zip:" ) :
129- raise ImportError (f"{ module . __spec__ .name !r} is not a zip module" )
128+ origin = spec .origin and remove_prefix ( spec . origin , "zip:" )
129+ if not origin :
130+ raise ImportError (f"{ spec .name !r} is not a zip module" )
130131
131- zipname , slash , path = origin [ len ( "zip:" ) :] .partition ("/" )
132+ zipname , slash , path = origin .partition ("/" )
132133 return cls ._packages [zipname ].read (path ).decode ()
133134
134135 @classmethod
@@ -141,6 +142,13 @@ def exec_module(cls, module):
141142 _bootstrap ._call_with_frames_removed (exec , code , module .__dict__ )
142143
143144
145+ def remove_prefix (s , prefix ):
146+ if s .startswith (prefix ):
147+ return s [len (prefix ) :] # noqa: E203
148+ else :
149+ return None
150+
151+
144152_zip_searchorder = (
145153 ("/__init__.pyc" , True , True ),
146154 ("/__init__.py" , False , True ),
0 commit comments