Skip to content

Commit 4b72be5

Browse files
committed
[GR-21590] Update imports
PullRequest: graalpython/2150
2 parents 8d87fda + 3c593f3 commit 4b72be5

File tree

7 files changed

+74
-14
lines changed

7 files changed

+74
-14
lines changed

ci.jsonnet

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{ "overlay": "955765a94e2eaed92fef6480886516843fb127f6" }
1+
{ "overlay": "6176531f89b51af931ba73cc53df24b7457bc46f" }

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@
3838
*graalpython.lib-python.3.test.test_ftplib.TestIPv6Environment.test_makepasv
3939
*graalpython.lib-python.3.test.test_ftplib.TestIPv6Environment.test_makeport
4040
*graalpython.lib-python.3.test.test_ftplib.TestIPv6Environment.test_transfer
41+
*graalpython.lib-python.3.test.test_ftplib.TestMain.test_main
4142
*graalpython.lib-python.3.test.test_ftplib.TestTLS_FTPClass.test_auth_issued_twice
43+
*graalpython.lib-python.3.test.test_ftplib.TestTLS_FTPClass.test_ccc
4244
*graalpython.lib-python.3.test.test_ftplib.TestTLS_FTPClass.test_check_hostname
4345
*graalpython.lib-python.3.test.test_ftplib.TestTLS_FTPClass.test_context
4446
*graalpython.lib-python.3.test.test_ftplib.TestTLS_FTPClass.test_control_connection

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,3 +120,4 @@
120120
*graalpython.lib-python.3.test.test_re.ReTests.test_symbolic_refs
121121
*graalpython.lib-python.3.test.test_re.ReTests.test_unlimited_zero_width_repeat
122122
*graalpython.lib-python.3.test.test_re.ReTests.test_weakref
123+
*graalpython.lib-python.3.test.test_re.ReTests.test_zerowidth

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

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@
121121
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
122122
import com.oracle.truffle.api.RootCallTarget;
123123
import com.oracle.truffle.api.TruffleFile;
124-
import com.oracle.truffle.api.TruffleLanguage;
125124
import com.oracle.truffle.api.TruffleLanguage.Env;
126125
import com.oracle.truffle.api.TruffleLogger;
127126
import com.oracle.truffle.api.dsl.Cached;
@@ -768,7 +767,8 @@ private void validate(HashingStorage dictStorage) {
768767
@GenerateNodeFactory
769768
public abstract static class JavaExtendNode extends PythonUnaryBuiltinNode {
770769
@Specialization
771-
Object doIt(Object value) {
770+
Object doIt(Object value,
771+
@CachedLibrary(limit = "3") InteropLibrary lib) {
772772
if (ImageInfo.inImageBuildtimeCode()) {
773773
CompilerDirectives.transferToInterpreterAndInvalidate();
774774
throw new UnsupportedOperationException(ErrorMessages.CANT_EXTEND_JAVA_CLASS_NOT_JVM);
@@ -779,21 +779,19 @@ Object doIt(Object value) {
779779
}
780780

781781
Env env = getContext().getEnv();
782-
if (!isType(value, env)) {
782+
if (!isType(value, env, lib)) {
783783
throw raise(TypeError, ErrorMessages.CANT_EXTEND_JAVA_CLASS_NOT_TYPE, value);
784784
}
785785

786-
final Class<?>[] types = new Class<?>[1];
787-
types[0] = (Class<?>) env.asHostObject(value);
788786
try {
789-
return env.createHostAdapterClass(types);
787+
return env.createHostAdapter(new Object[]{value});
790788
} catch (Exception ex) {
791789
throw raise(TypeError, ex.getMessage(), ex);
792790
}
793791
}
794792

795-
protected static boolean isType(Object obj, TruffleLanguage.Env env) {
796-
return env.isHostObject(obj) && env.asHostObject(obj) instanceof Class<?>;
793+
protected static boolean isType(Object obj, Env env, InteropLibrary lib) {
794+
return env.isHostObject(obj) && (env.isHostSymbol(obj) || lib.isMetaObject(obj));
797795
}
798796

799797
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
From 38f7d1bd9869f7eeff41530e8e451caa026ef327 Mon Sep 17 00:00:00 2001
2+
From: Michael Simacek <[email protected]>
3+
Date: Mon, 14 Feb 2022 11:24:57 +0100
4+
Subject: [PATCH] Adapt for GraalPython
5+
6+
---
7+
_pytest/_code/code.py | 20 +++++++++++---------
8+
_pytest/assertion/__init__.py | 2 +-
9+
2 files changed, 12 insertions(+), 10 deletions(-)
10+
11+
diff --git a/_pytest/_code/code.py b/_pytest/_code/code.py
12+
index 5b758a8..869ad4e 100644
13+
--- a/_pytest/_code/code.py
14+
+++ b/_pytest/_code/code.py
15+
@@ -256,15 +256,17 @@ class TracebackEntry:
16+
if key is not None:
17+
astnode = astcache.get(key, None)
18+
start = self.getfirstlinesource()
19+
- try:
20+
- astnode, _, end = getstatementrange_ast(
21+
- self.lineno, source, astnode=astnode
22+
- )
23+
- except SyntaxError:
24+
- end = self.lineno + 1
25+
- else:
26+
- if key is not None and astcache is not None:
27+
- astcache[key] = astnode
28+
+ # GraalPython: no support for the ast module so the source cannot be retrieved correctly
29+
+ # try:
30+
+ # astnode, _, end = getstatementrange_ast(
31+
+ # self.lineno, source, astnode=astnode
32+
+ # )
33+
+ # except SyntaxError:
34+
+ # end = self.lineno + 1
35+
+ # else:
36+
+ # if key is not None and astcache is not None:
37+
+ # astcache[key] = astnode
38+
+ end = -1
39+
return source[start:end]
40+
41+
source = property(getsource)
42+
diff --git a/_pytest/assertion/__init__.py b/_pytest/assertion/__init__.py
43+
index 480a26a..2466ea8 100644
44+
--- a/_pytest/assertion/__init__.py
45+
+++ b/_pytest/assertion/__init__.py
46+
@@ -26,7 +26,7 @@ def pytest_addoption(parser: Parser) -> None:
47+
action="store",
48+
dest="assertmode",
49+
choices=("rewrite", "plain"),
50+
- default="rewrite",
51+
+ default="plain",
52+
metavar="MODE",
53+
help=(
54+
"Control assertion debugging tools.\n"
55+
--
56+
2.34.1
57+

mx.graalpython/mx_graalpython.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ def retag_unittests(args):
302302
parser.add_argument('--upload-results-to')
303303
parser.add_argument('--inspect', action='store_true')
304304
parser.add_argument('-debug-java', action='store_true')
305+
parser.add_argument('--jvm', action='store_true')
305306
parsed_args, remaining_args = parser.parse_known_args(args)
306307
env = os.environ.copy()
307308
env.update(
@@ -320,7 +321,8 @@ def retag_unittests(args):
320321
'graalpython/com.oracle.graal.python.test/src/tests/test_tagged_unittests.py',
321322
'--retag'
322323
]
323-
mx.run([python_svm()] + args + remaining_args, env=env)
324+
vm = python_svm() if not parsed_args.jvm else python_gvm_with_assertions()
325+
mx.run([vm] + args + remaining_args, env=env)
324326
if parsed_args.upload_results_to:
325327
with tempfile.TemporaryDirectory(prefix='graalpython-retagger-') as d:
326328
filename = os.path.join(d, 'unittest-tags-{}.tar.bz2'.format(sys.platform))
@@ -1158,7 +1160,7 @@ def update_import_cmd(args):
11581160
exec(f.read(), d, d) # pylint: disable=exec-used;
11591161
for suite in d["suite"].get("imports", {}).get("suites", []):
11601162
import_name = suite["name"]
1161-
if suite.get("version") and import_name not in local_names:
1163+
if suite.get("version") and import_name not in local_names and import_name != 'library-tester':
11621164
imports_to_update.add(import_name)
11631165

11641166
revisions = {}

mx.graalpython/suite.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,23 +44,23 @@
4444
},
4545
{
4646
"name": "tools",
47-
"version": "aebf9889d1856b765b9498089e09ad255765cb4e",
47+
"version": "9b25754d49ca0fec016b1f4c03999f09fdb07404",
4848
"subdir": True,
4949
"urls": [
5050
{"url": "https://github.com/oracle/graal", "kind": "git"},
5151
],
5252
},
5353
{
5454
"name": "sulong",
55-
"version": "aebf9889d1856b765b9498089e09ad255765cb4e",
55+
"version": "9b25754d49ca0fec016b1f4c03999f09fdb07404",
5656
"subdir": True,
5757
"urls": [
5858
{"url": "https://github.com/oracle/graal", "kind": "git"},
5959
]
6060
},
6161
{
6262
"name": "regex",
63-
"version": "aebf9889d1856b765b9498089e09ad255765cb4e",
63+
"version": "9b25754d49ca0fec016b1f4c03999f09fdb07404",
6464
"subdir": True,
6565
"urls": [
6666
{"url": "https://github.com/oracle/graal", "kind": "git"},

0 commit comments

Comments
 (0)