Skip to content

Commit 1873128

Browse files
committed
[GR-21590] Update Python imports
PullRequest: graalpython/2003
2 parents cd15375 + a7b2503 commit 1873128

File tree

18 files changed

+138
-145
lines changed

18 files changed

+138
-145
lines changed

ci.jsonnet

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{ "overlay": "e43ce8dd99f09ee14703d1a6703658ee796059f1" }
1+
{ "overlay": "441cccb09e2ddd78106526da13cd2bf23af74c26" }

graalpython/com.oracle.graal.python.test/src/graalpytest.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@
5959
'test_import',
6060
'test_subprocess',
6161
'test_posix',
62+
'test_io',
63+
'test_fileio',
64+
'test_imaplib',
65+
'test_multiprocessing_spawn',
6266
# trying to avoid transient issues there, not sure about the reason
6367
'test_unittest',
6468
]

graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_exceptionobject.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,14 @@ def test_exc_info(self):
6666
tester = TestExcInfo()
6767
try:
6868
raise IndexError
69-
except:
69+
except IndexError:
7070
exc_type = tester.get_exc_info()
7171
assert exc_type == IndexError
7272

7373
# do a second time because this time we won't do a stack walk
74-
exc_type = tester.get_exc_info()
75-
assert exc_type == IndexError
74+
# disabled due to GR-34711
75+
# exc_type = tester.get_exc_info()
76+
# assert exc_type == IndexError
7677
else:
7778
assert False
7879

graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_codecencodings_cn.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,3 @@
1919
*graalpython.lib-python.3.test.test_codecencodings_cn.Test_GBK.test_streamwriter
2020
*graalpython.lib-python.3.test.test_codecencodings_cn.Test_GBK.test_streamwriter_reset_no_pending
2121
*graalpython.lib-python.3.test.test_codecencodings_cn.Test_GBK.test_xmlcharrefreplace
22-
*graalpython.lib-python.3.test.test_codecencodings_cn.Test_HZ.test_streamwriter_reset_no_pending

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinConstructors.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2164,7 +2164,7 @@ Object typeNew(VirtualFrame frame, Object cls, Object wName, PTuple bases, PDict
21642164
Object winner = calculateMetaclass(frame, metaclass, bases, getClassNode, lookupMroEntriesNode);
21652165
if (winner != metaclass) {
21662166
Object newFunc = getNewFuncNode.execute(winner);
2167-
if (newFunc instanceof PBuiltinFunction && (((PBuiltinFunction) newFunc).getFunctionRootNode() == getRootNode())) {
2167+
if (newFunc instanceof PBuiltinFunction && (((PBuiltinFunction) newFunc).getFunctionRootNode().getCallTarget() == getRootNode().getCallTarget())) {
21682168
metaclass = winner;
21692169
// the new metaclass has the same __new__ function as we are in, continue
21702170
} else {

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/resources/reflect-config.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,14 @@
5050
{
5151
"name":"com.ibm.icu.charset.CharsetHZ",
5252
"methods":[{"name":"<init>","parameterTypes":["java.lang.String", "java.lang.String", "java.lang.String[]"]}]
53+
},
54+
{
55+
"name":"java.util.Locale",
56+
"fields":[{"name":"US"}],
57+
"methods":[{"name":"setDefault","parameterTypes":["java.util.Locale"]}]
58+
},
59+
{
60+
"name":"java.lang.System",
61+
"methods":[{"name":"getProperty","parameterTypes":["java.lang.String"]}]
5362
}
5463
]

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/runtime/ExecutionContext.java

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,9 @@ private static IndirectCallState enter(VirtualFrame frame, PythonThreadState pyt
409409
public static void exit(VirtualFrame frame, PythonLanguage language, PythonContext context, Object savedState) {
410410
if (savedState != null && frame != null && context != null) {
411411
exit(frame, context.getThreadState(language), savedState);
412+
return;
412413
}
414+
assert savedState == null : "tried to exit an indirect call with state, but without frame/context";
413415
}
414416

415417
public static void exit(VirtualFrame frame, PNodeWithRaiseAndIndirectCall indirectCallNode, Object savedState) {
@@ -418,24 +420,28 @@ public static void exit(VirtualFrame frame, PNodeWithRaiseAndIndirectCall indire
418420
if (context != null) {
419421
PythonLanguage language = indirectCallNode.getLanguage();
420422
exit(frame, context.getThreadState(language), savedState);
423+
return;
421424
}
422425
}
426+
assert savedState == null : "tried to exit an indirect call with state, but without frame/context";
423427
}
424428

425429
/**
426430
* @see #exit(VirtualFrame, PythonLanguage, PythonContext, Object)
427431
*/
428432
public static void exit(VirtualFrame frame, PythonThreadState pythonThreadState, Object savedState) {
429-
if (frame == null || savedState == null) {
433+
if (frame == null) {
434+
assert savedState == null : "tried to exit an indirect call with state, but without frame";
435+
return;
436+
}
437+
if (savedState == null) {
430438
return;
431439
}
432440
IndirectCallState state = (IndirectCallState) savedState;
433441
if (state.info != null) {
434442
pythonThreadState.popTopFrameInfo();
435443
}
436-
if (state.curExc != null) {
437-
pythonThreadState.setCaughtException(state.curExc);
438-
}
444+
pythonThreadState.setCaughtException(state.curExc);
439445
}
440446
}
441447

@@ -476,13 +482,6 @@ private static PFrame.Reference enter(PythonThreadState threadState, Object[] pA
476482

477483
if (needsExceptionState) {
478484
PException curExc = threadState.getCaughtException();
479-
if (curExc == null) {
480-
CompilerDirectives.transferToInterpreter();
481-
PException fromStackWalk = GetCaughtExceptionNode.fullStackWalk();
482-
curExc = fromStackWalk != null ? fromStackWalk : PException.NO_EXCEPTION;
483-
// now, set in our args, such that we won't do this again
484-
threadState.setCaughtException(curExc);
485-
}
486485
PArguments.setException(pArguments, curExc);
487486
}
488487
return popTopFrameInfo;

graalpython/lib-graalpython/__graalpython__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
class SysState:
4343
def __init__(self):
44-
self.recursionlimit = 1000
44+
self.recursionlimit = 8000 if __graalpython__.is_native else 1000
4545
self.checkinterval = 100
4646
self.switchinterval = 0.005
4747

graalpython/lib-graalpython/java.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ def is_java_package(name):
4848
package = type("java.lang.Package")
4949
return any(p.getName().startswith(name) for p in package.getPackages())
5050
except KeyError:
51+
if name in ("java.lang", "java.util"):
52+
# Some well-known packages that we always allow
53+
return True
5154
if sys.flags.verbose:
5255
from _warnings import warn
5356
warn("Host lookup allowed, but java.lang.Package not available. Importing from Java cannot work.")
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
DISABLE_INSTALLABLES=true
22
DYNAMIC_IMPORTS=/substratevm
3-
COMPONENTS=LibGraal,Graal.Python
4-
FORCE_BASH_LAUNCHERS=true
5-
SKIP_LIBRARIES=
3+
NATIVE_IMAGES=lib:jvmcicompiler
64
NO_LICENSES=true

0 commit comments

Comments
 (0)