@@ -118,7 +118,7 @@ class _GetbeamlineparsReturn(TypedDict):
118118print ("\n genie_python version " + VERSION )
119119
120120MIN_SUPPORTED_PYTHON_VERSION = (3 , 11 , 0 )
121- MAX_SUPPORTED_PYTHON_VERSION = (3 , 12 , 999 )
121+ MAX_SUPPORTED_PYTHON_VERSION = (3 , 13 , 999 )
122122
123123if not (MIN_SUPPORTED_PYTHON_VERSION <= sys .version_info [0 :3 ] <= MAX_SUPPORTED_PYTHON_VERSION ):
124124 message = (
@@ -1562,16 +1562,26 @@ def __load_module(name: str, directory: str) -> types.ModuleType:
15621562 raise ValueError (f"Cannot find spec for module { name } in { directory } " )
15631563 module = importlib .util .module_from_spec (spec )
15641564
1565- if module .__file__ is None :
1566- raise ValueError (f"Module { name } has no __file__ attribute" )
1565+ err_msg = (
1566+ f"Cannot load script '{ name } ' as its name clashes with a standard python module "
1567+ f"or with a module accessible elsewhere on the python path.\n "
1568+ f"The conflicting module was '{ module } '.\n "
1569+ f"If this is a user script, rename the user script to avoid the clash."
1570+ )
1571+
1572+ try :
1573+ module_file = module .__file__
1574+ except AttributeError :
1575+ raise ValueError (err_msg ) from None
1576+
1577+ if module_file is None :
1578+ raise ValueError (err_msg )
1579+
1580+ module_location = str (module_file )
1581+
1582+ if os .path .normpath (os .path .dirname (module_location )) != os .path .normpath (directory ):
1583+ raise ValueError (err_msg )
15671584
1568- if os .path .normpath (os .path .dirname (module .__file__ )) != os .path .normpath (directory ):
1569- raise ValueError (
1570- f"Cannot load script '{ name } ' as its name clashes with a standard python module "
1571- f"or with a module accessible elsewhere on the python path.\n "
1572- f"The conflicting module was at '{ module .__file__ } '.\n "
1573- f"If this is a user script, rename the user script to avoid the clash."
1574- )
15751585 sys .modules [name ] = module
15761586 loader = spec .loader
15771587 if loader is None :
0 commit comments