@@ -241,11 +241,10 @@ def _unregister(self, cls: Type, force: bool = False) -> None:
241241 _debug ("Done" )
242242
243243
244- def _get_serverdll (handle : Optional [ int ] ) -> str :
244+ def _get_serverdll (handle : int ) -> str :
245245 """Return the pathname of the dll hosting the COM object."""
246- if handle is not None :
247- return GetModuleFileName (handle , 260 )
248- return _ctypes .__file__
246+ assert isinstance (handle , int )
247+ return GetModuleFileName (handle , 260 )
249248
250249
251250class RegistryEntries (abc .ABC ):
@@ -295,7 +294,9 @@ def __iter__(self) -> Iterator[_Entry]:
295294 if localsvr_ctx and self ._frozendllhandle is None :
296295 yield from _iter_frozen_local_ctx_entries (self ._cls , reg_clsid )
297296 if inprocsvr_ctx and self ._frozen == "dll" :
298- yield from _iter_inproc_ctx_entries (reg_clsid , self ._frozendllhandle )
297+ assert self ._frozendllhandle is not None
298+ frozen_dll = _get_serverdll (self ._frozendllhandle )
299+ yield from _iter_inproc_ctx_entries (reg_clsid , frozen_dll )
299300 yield from _iter_inproc_threading_model_entries (self ._cls , reg_clsid )
300301 yield from _iter_tlib_entries (self ._cls , reg_clsid )
301302
@@ -314,7 +315,7 @@ def __iter__(self) -> Iterator[_Entry]:
314315 if localsvr_ctx :
315316 yield from _iter_interp_local_ctx_entries (self ._cls , reg_clsid )
316317 if inprocsvr_ctx :
317- yield from _iter_inproc_ctx_entries (reg_clsid , None )
318+ yield from _iter_inproc_ctx_entries (reg_clsid , _ctypes . __file__ )
318319 # only for non-frozen inproc servers the PythonPath/PythonClass is needed.
319320 yield from _iter_inproc_python_entries (self ._cls , reg_clsid )
320321 yield from _iter_inproc_threading_model_entries (self ._cls , reg_clsid )
@@ -388,17 +389,10 @@ def _iter_frozen_local_ctx_entries(cls: Type, reg_clsid: str) -> Iterator[_Entry
388389 yield (HKCR , rf"CLSID\{ reg_clsid } \LocalServer32" , "" , f"{ exe } " )
389390
390391
391- def _iter_inproc_ctx_entries (
392- reg_clsid : str , frozendllhandle : Optional [int ]
393- ) -> Iterator [_Entry ]:
392+ def _iter_inproc_ctx_entries (reg_clsid : str , dllfile : str ) -> Iterator [_Entry ]:
394393 # Register InprocServer32 only when run from script or from
395394 # py2exe dll server, not from py2exe exe server.
396- yield (
397- HKCR ,
398- rf"CLSID\{ reg_clsid } \InprocServer32" ,
399- "" ,
400- _get_serverdll (frozendllhandle ),
401- )
395+ yield (HKCR , rf"CLSID\{ reg_clsid } \InprocServer32" , "" , dllfile )
402396
403397
404398def _iter_inproc_python_entries (cls : Type , reg_clsid : str ) -> Iterator [_Entry ]:
0 commit comments