Skip to content

Commit 1f2703f

Browse files
committed
Merge branch 'master' into feature/GR-18284
# Conflicts: # graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java
2 parents d796562 + 99e9963 commit 1f2703f

File tree

65 files changed

+2395
-597
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+2395
-597
lines changed

SECURITY.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Reporting Security Vulnerabilities
2+
3+
The GraalVM team values the independent security research community and believes
4+
that responsible disclosure of security vulnerabilities in GraalVM Community
5+
Edition as well as GraalVM Enterprise Edition helps us ensure the security and
6+
privacy of all our users.
7+
8+
If you believe you have found a security vulnerability, please submit a report
9+
to [email protected] preferably with a proof of concept. Please refer to
10+
[Reporting
11+
Vulnerabilities](https://www.oracle.com/corporate/security-practices/assurance/vulnerability/reporting.html)
12+
for additional information including our public encryption key for secure
13+
email. We ask that you do not contact project contributors directly or through
14+
other channels about a report.
15+
16+
### Security Updates, Alerts and Bulletins
17+
18+
GraalVM Community Edition security updates will be released on a quarterly basis
19+
in conjunction withe GraalVM Enterprise Edition security updates that are part
20+
of the Oracle Critical Patch Update program. Security updates are released on
21+
the Tuesday closest to the 17th day of January, April, July and October. A
22+
pre-release announcement will be published on the Thursday preceding each
23+
Critical Patch Update release. For additional information including past
24+
advisories, please refer to [Security
25+
Alerts](https://www.oracle.com/security-alerts/).
26+
27+
### Security-Related Information
28+
29+
Please refer to the [GraalVM Security
30+
Guide](https://www.graalvm.org/docs/security-guide/) for security related topics
31+
such as how to support trusted and less trusted code execution using the Truffle
32+
language framework, or compiler mitigations for transitive execution
33+
attacks. However please note that we do not currently support the execution of
34+
untrusted or adversarial code. Non-vulnerability related security issues may be
35+
discussed on GitHub Issues or the Security channel in the [GraalVM Slack
36+
Workspace](https://graalvm.slack.com/)
37+

ci.jsonnet

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{ "overlay": "6e0694bba348c69f01d4fb3f7d7ad2e128a93e94" }
1+
{ "overlay": "c949a434d869d789978d54fd6f3e8ebe3a03c82a" }

graalpython/com.oracle.graal.python.benchmarks/python/meso/raytrace-simple.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ def baseColourAt(self, p):
351351
else:
352352
return self.baseColour
353353

354-
def _main(width=150, height=150):
354+
def _main(width=400, height=400):
355355
Canvas = PpmCanvas
356356
c = Canvas(width,height)
357357
s = Scene()

graalpython/com.oracle.graal.python.shell/src/com/oracle/graal/python/shell/ConsoleHandler.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* The Universal Permissive License (UPL), Version 1.0
@@ -88,12 +88,15 @@ public void setHistory(BooleanSupplier shouldRecord, IntSupplier getSize, Consum
8888
public InputStream createInputStream() {
8989
return new InputStream() {
9090
byte[] buffer = null;
91-
int pos = -1;
91+
int pos = 0;
9292

9393
@Override
9494
public int read() throws IOException {
95-
if (buffer == null) {
95+
if (pos < 0) {
9696
pos = 0;
97+
return -1;
98+
} else if (buffer == null) {
99+
assert pos == 0;
97100
String line = readLine(false);
98101
if (line == null) {
99102
return -1;
@@ -102,6 +105,7 @@ public int read() throws IOException {
102105
}
103106
if (pos == buffer.length) {
104107
buffer = null;
108+
pos = -1;
105109
return '\n';
106110
} else {
107111
return buffer[pos++];

graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/datatype/DictTests.java

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, 2018, Oracle and/or its affiliates.
2+
* Copyright (c) 2017, 2020, Oracle and/or its affiliates.
33
* Copyright (c) 2013, Regents of the University of California
44
*
55
* All rights reserved.
@@ -54,36 +54,78 @@ public void del() {
5454
assertPrints("{3: 4}\n", source);
5555
}
5656

57+
@Test
58+
public void dict() {
59+
String source = "print(type({}))\n" +
60+
"print(type(iter({1: 'a', 2: 'b'})))\n" +
61+
"print({})\n" +
62+
"print({1: 'a'})\n" +
63+
"print({1: 'a', 2: 'b'})\n";
64+
65+
assertPrints("<class 'dict'>\n" +
66+
"<class 'dict_keyiterator'>\n" +
67+
"{}\n" +
68+
"{1: 'a'}\n" +
69+
"{1: 'a', 2: 'b'}\n", source);
70+
71+
source = "d = {1: 1}\n" +
72+
"d.__setitem__(2, d)\n" +
73+
"print(d)\n";
74+
assertPrints("{1: 1, 2: {...}}\n", source);
75+
}
76+
5777
@Test
5878
public void dictViewKeys() {
5979
String source = "print(type({}.keys()))\n" +
6080
"print(type(iter({1: 'a', 2: 'b'}.keys())))\n" +
81+
"print({}.keys())\n" +
82+
"print({1: 'a'}.keys())\n" +
6183
"print({1: 'a', 2: 'b'}.keys())\n";
6284

6385
assertPrints("<class 'dict_keys'>\n" +
64-
"<class 'dict_keysiterator'>\n" +
86+
"<class 'dict_keyiterator'>\n" +
87+
"dict_keys([])\n" +
88+
"dict_keys([1])\n" +
6589
"dict_keys([1, 2])\n", source);
6690
}
6791

6892
@Test
6993
public void dictViewValues() {
7094
String source = "print(type({}.values()))\n" +
7195
"print(type(iter({1: 'a', 2: 'b'}.values())))\n" +
96+
"print({}.values())\n" +
97+
"print({1: 'a'}.values())\n" +
7298
"print({1: 'a', 2: 'b'}.values())\n";
7399

74100
assertPrints("<class 'dict_values'>\n" +
75-
"<class 'dict_valuesiterator'>\n" +
101+
"<class 'dict_valueiterator'>\n" +
102+
"dict_values([])\n" +
103+
"dict_values(['a'])\n" +
76104
"dict_values(['a', 'b'])\n", source);
105+
106+
source = "d = {1: 1}\n" +
107+
"d.__setitem__(2, d)\n" +
108+
"print(d.values())\n";
109+
assertPrints("dict_values([1, {1: 1, 2: {...}}])\n", source);
77110
}
78111

79112
@Test
80113
public void dictViewItems() {
81114
String source = "print(type({}.items()))\n" +
82115
"print(type(iter({1: 'a', 2: 'b'}.items())))\n" +
116+
"print({}.items())\n" +
117+
"print({1: 'a'}.items())\n" +
83118
"print({1: 'a', 2: 'b'}.items())\n";
84119

85120
assertPrints("<class 'dict_items'>\n" +
86-
"<class 'dict_itemsiterator'>\n" +
121+
"<class 'dict_itemiterator'>\n" +
122+
"dict_items([])\n" +
123+
"dict_items([(1, 'a')])\n" +
87124
"dict_items([(1, 'a'), (2, 'b')])\n", source);
125+
126+
source = "d = {1: 1}\n" +
127+
"d.__setitem__(2, d)\n" +
128+
"print(d.items())\n";
129+
assertPrints("dict_items([(1, 1), (2, {1: 1, 2: {...}})])\n", source);
88130
}
89131
}

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

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,21 @@ def __init__(self):
117117
self.passed = 0
118118
self.failed = 0
119119

120+
def get_useful_frame(self, tb):
121+
from traceback import extract_tb
122+
frame_summaries = extract_tb(tb)
123+
frame_summaries.reverse()
124+
for summary in frame_summaries:
125+
# Skip frame summary entries that refer to this file. These summaries will mostly be there because of the
126+
# assert functions and their location is not interesting.
127+
if summary[0] != __file__:
128+
return summary
129+
130+
120131
def run_safely(self, func, print_immediately=False):
121132
if verbose:
122133
with print_lock:
123-
print(u"\n\t\u21B3 ", func.__name__, " ", end="")
134+
print(u"\n\t\u21B3 ", func.__name__, " ", end="", flush=True)
124135
try:
125136
func()
126137
except BaseException as e:
@@ -132,8 +143,7 @@ def run_safely(self, func, print_immediately=False):
132143
code = func.__code__
133144
_, _, tb = sys.exc_info()
134145
try:
135-
from traceback import extract_tb
136-
filename, line, func, text = extract_tb(tb)[-1]
146+
filename, line, func, text = self.get_useful_frame(tb)
137147
self.exceptions.append(
138148
("In test '%s': %s:%d (%s)" % (code.co_filename, filename, line, func), e)
139149
)
@@ -152,18 +162,24 @@ def run_test(self, func):
152162
pass
153163
else:
154164
def do_run():
165+
start = time.monotonic()
155166
r = self.run_safely(func)
167+
end = time.monotonic() - start
156168
with print_lock:
157-
self.success() if r else self.failure()
169+
self.success(end) if r else self.failure(end)
158170
ThreadPool.start(do_run)
159171

160-
def success(self):
172+
def success(self, time):
161173
self.passed += 1
174+
if verbose:
175+
print("[%.3fs]" % time, end=" ")
162176
print(".", end="", flush=True)
163177

164-
def failure(self):
178+
def failure(self, time):
165179
self.failed += 1
166180
fail_msg = FAIL + BOLD + "F" + ENDC if verbose else "F"
181+
if verbose:
182+
print("[%.3fs]" % time, end=" ")
167183
print(fail_msg, end="", flush=True)
168184

169185
def assertIsInstance(self, value, cls):
@@ -213,6 +229,11 @@ def assertGreater(self, expected, actual, msg=None):
213229
msg = "Expected '%r' to be greater than '%r'" % (actual, expected)
214230
assert expected > actual, msg
215231

232+
def assertGreaterEqual(self, expected, actual, msg=None):
233+
if not msg:
234+
msg = "Expected '%r' to be greater than or equal to '%r'" % (actual, expected)
235+
assert expected >= actual, msg
236+
216237
def assertSequenceEqual(self, expected, actual, msg=None):
217238
if not msg:
218239
msg = "Expected '%r' to be equal to '%r'" % (actual, expected)

graalpython/com.oracle.graal.python.test/src/tests/test_dict.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,24 @@ def test_fromkeys():
103103
assert set(d.keys()) == {'a', 'b', 'c'}
104104
assert set(d.values()) == {o}
105105

106+
class preset(dict):
107+
def __init__(self):
108+
self['a'] = 1
109+
assert preset.fromkeys(['b']) == {'a':1, 'b':None}
110+
111+
class morethanoneinitargraiseserror(dict):
112+
def __init__(self, anotherArg):
113+
self.__init__()
114+
assert_raises(TypeError, morethanoneinitargraiseserror.fromkeys, [1])
115+
116+
class nosetitem:
117+
pass
118+
119+
class nosetitem2(dict):
120+
def __new__(cls):
121+
return nosetitem()
122+
assert_raises(TypeError, nosetitem2.fromkeys, [1])
123+
106124

107125
def test_init():
108126
d = dict(a=1, b=2, c=3)

0 commit comments

Comments
 (0)