File tree Expand file tree Collapse file tree 1 file changed +14
-9
lines changed
graalpython/lib-graalpython Expand file tree Collapse file tree 1 file changed +14
-9
lines changed Original file line number Diff line number Diff line change 43
43
class JavaPackageLoader :
44
44
@staticmethod
45
45
def is_java_package (name ):
46
- return any (p .getName ().startswith (name ) for p in type ("java.lang.Package" ).getPackages ())
46
+ try :
47
+ package = type ("java.lang.Package" )
48
+ return any (p .getName ().startswith (name ) for p in package .getPackages ())
49
+ except KeyError :
50
+ return False
47
51
48
52
@staticmethod
49
53
def _make_getattr (modname ):
50
54
modname = modname + "."
51
55
def __getattr__ (key , default = None ):
52
- loadname = modname + key
53
- if JavaPackageLoader .is_java_package (loadname ):
54
- return JavaPackageLoader ._create_module (loadname )
55
- else :
56
- try :
57
- return type (modname + key )
58
- except KeyError :
59
- raise AttributeError (key )
56
+ if sys .graal_python_host_import_enabled :
57
+ loadname = modname + key
58
+ if JavaPackageLoader .is_java_package (loadname ):
59
+ return JavaPackageLoader ._create_module (loadname )
60
+ else :
61
+ try :
62
+ return type (modname + key )
63
+ except KeyError :
64
+ raise AttributeError (key )
60
65
return __getattr__
61
66
62
67
@staticmethod
You can’t perform that action at this time.
0 commit comments