Skip to content

Commit 6fc08f1

Browse files
committed
Merge branch 'master' into topic/GR-21836
2 parents b7928b0 + c541f0e commit 6fc08f1

File tree

159 files changed

+2088
-1376
lines changed

Some content is hidden

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

159 files changed

+2088
-1376
lines changed

graalpython/com.oracle.graal.python.cext/src/typeobject.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,12 @@ int PyType_Ready(PyTypeObject* cls) {
512512
ADD_SLOT("__getattr__", cls->tp_getattro, -2);
513513
ADD_SLOT_PRIMITIVE("__setattr__", cls->tp_setattro, -3);
514514
ADD_SLOT_CONV("__clear__", native_int_to_bool, cls->tp_clear, -1, NULL);
515-
if (cls->tp_richcompare) {
515+
516+
/* IMPORTANT NOTE: If the class already provides 'tp_richcompare' but this is the default
517+
'object.__truffle_richcompare__' function, then we need to break a recursive cycle since
518+
the default function dispatches to the individual comparison functions which would in
519+
this case again invoke 'object.__truffle_richcompare__'. */
520+
if (cls->tp_richcompare && cls->tp_richcompare != PyBaseObject_Type.tp_richcompare) {
516521
ADD_SLOT_CONV("__compare__", native_to_java_stealing_exported, cls->tp_richcompare, -3, JWRAPPER_RICHCMP);
517522
ADD_SLOT_CONV("__lt__", native_to_java_stealing_exported, cls->tp_richcompare, -2, JWRAPPER_LT);
518523
ADD_SLOT_CONV("__le__", native_to_java_stealing_exported, cls->tp_richcompare, -2, JWRAPPER_LE);

graalpython/com.oracle.graal.python.cext/src/unicodeobject.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -687,10 +687,10 @@ void* native_unicode_as_string(PyObject *string) {
687687
return NULL;
688688
}
689689
_PyUnicode_CONVERT_BYTES(Py_UCS2, Py_UCS4, start, start + len, target);
690-
result = polyglot_from_string_n((const char *)target, sizeof(Py_UCS4) * len, "UTF-32");
690+
result = polyglot_from_string_n((const char *)target, sizeof(Py_UCS4) * len, "UTF-32LE");
691691
free(target);
692692
return result;
693693
}
694694
assert(kind == PyUnicode_4BYTE_KIND);
695-
return polyglot_from_string_n((const char *)data, sizeof(Py_UCS4) * len, "UTF-32");
695+
return polyglot_from_string_n((const char *)data, sizeof(Py_UCS4) * len, "UTF-32LE");
696696
}

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

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,30 @@
8080
PTRN_TEST_STATUS_INDIVIDUAL = re.compile(r"(?P<name>test[\w_]+ \(.+?\)) ... (?P<status>.+)")
8181
PTRN_TEST_STATUS_ERROR = re.compile(r"(?P<status>.+): (?P<name>test[\w_]+ \(.+?\))")
8282

83+
TEST_TYPES = ('array','buffer','code','frame','long','memoryview','unicode','exceptions',
84+
'baseexception','range','builtin','bytes','thread','property','class','dictviews',
85+
'sys','imp','rlcompleter','types','coroutines','dictcomps','int_literal','mmap',
86+
'module','numeric_tower','syntax','traceback','typechecks','int','keyword','raise',
87+
'descr','generators','list','complex','tuple','enumerate','super','float',
88+
'bool','fstring','dict','iter','string','scope','with','set')
89+
90+
TEST_APP_SCRIPTING = ('test_json','csv','io','memoryio','bufio','fileio','file','fileinput','tempfile',
91+
'pickle','pickletester','pickle','picklebuffer','pickletools','codecs','functools',
92+
'itertools','math','operator','zlib','zipimport_support','zipfile','zipimport',
93+
'zipapp','gzip','bz2','builtin')
94+
95+
TEST_SERVER_SCRIPTING_DS = ('sqlite3','asyncio','marshal','select','crypt','ssl','uuid','multiprocessing',
96+
'fork','forkserver','main_handling','spawn','socket','socket','socketserver',
97+
'signal','mmap','resource','thread','dummy_thread','threading','threading_local',
98+
'threadsignals','dummy_threading','threadedtempfile','thread','hashlib','re',
99+
'pyexpat','locale','_locale','locale','c_locale_coercion','struct') + TEST_APP_SCRIPTING
100+
101+
102+
USE_CASE_GROUPS = {
103+
'Python Language and Built-in Types': TEST_TYPES,
104+
'Application Scripting': TEST_APP_SCRIPTING,
105+
'Server-Side Scripting and Data Science': TEST_SERVER_SCRIPTING_DS
106+
}
83107

84108
# ----------------------------------------------------------------------------------------------------------------------
85109
#
@@ -651,8 +675,6 @@ def _fmt(cmp):
651675
'''.format('\n'.join([_fmt(cmp) for cmp in components]))
652676

653677
def progress_bar(value, color='success'):
654-
if 0.0 <= value <= 1.0:
655-
value = 100 * value
656678
return '''
657679
<div class="progress">
658680
<div class="progress-bar progress-bar-{color}" role="progressbar" aria-valuenow="{value}"
@@ -777,6 +799,21 @@ def format_val(row, k):
777799
'<b>{}</b>'.format(r[Col.UNITTEST])
778800
for r in rows if r[Col.NUM_ERRORS] == -1
779801
])
802+
803+
usecase_scores = dict()
804+
for usecase_name, usecase_modules in USE_CASE_GROUPS.items():
805+
score_sum = 0
806+
for m in usecase_modules:
807+
for r in rows:
808+
if ("test_" + m + ".py") == r[Col.UNITTEST]:
809+
if r[Col.NUM_PASSES] > 0 and r[Col.NUM_TESTS] > 0:
810+
score_sum += r[Col.NUM_PASSES] / r[Col.NUM_TESTS]
811+
usecase_scores[usecase_name] = score_sum / len(usecase_modules)
812+
813+
814+
use_case_stats_info = ul("<b>Summary per Use Case</b>",
815+
[ grid((progress_bar(avg_score * 100, color="info"), 3), '<b>{}</b>'.format(usecase_name)) +
816+
grid(", ".join(USE_CASE_GROUPS[usecase_name])) for usecase_name, avg_score in usecase_scores.items()])
780817

781818
total_stats_info = ul("<b>Summary</b>", [
782819
grid('<b># total</b> unittests: {}'.format(totals[Stat.UT_TOTAL])),
@@ -791,7 +828,9 @@ def format_val(row, k):
791828

792829
table_stats = table('stats', CSV_HEADER, rows)
793830

794-
content = ' <br> '.join([total_stats_info, table_stats,
831+
content = ' <br> '.join([use_case_stats_info,
832+
total_stats_info,
833+
table_stats,
795834
missing_modules_info,
796835
cannot_import_modules_info,
797836
java_issues_info,

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ def test_str_subclass(self):
481481
obj = (PyUnicodeObject *) malloc(struct_size + (size + 1) * char_size);
482482
if (obj == NULL)
483483
return NULL;
484-
obj = PyObject_INIT(obj, &PyUnicode_Type);
484+
obj = (PyUnicodeObject *) PyObject_INIT(obj, testStrSubclassPtr);
485485
if (obj == NULL)
486486
return NULL;
487487
@@ -543,7 +543,8 @@ def test_str_subclass(self):
543543
int marker;""",
544544
tp_base="&PyUnicode_Type",
545545
tp_new="nstr_tpnew",
546-
post_ready_code="testStrSubclassPtr = &TestStrSubclassType; Py_INCREF(testStrSubclassPtr);"
546+
ready_code="TestStrSubclassType.tp_richcompare = PyUnicode_Type.tp_richcompare;",
547+
post_ready_code="testStrSubclassPtr = &TestStrSubclassType; Py_INCREF(testStrSubclassPtr);"
547548
)
548549
tester = TestStrSubclass("hello\nworld")
549550
assert tester == "hello\nworld"

graalpython/com.oracle.graal.python.test/src/tests/test_generator-expressions.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2018, 2019, Oracle and/or its affiliates.
1+
# Copyright (c) 2018, 2020, Oracle and/or its affiliates.
22
# Copyright (c) 2013, Regents of the University of California
33
#
44
# All rights reserved.
@@ -66,3 +66,6 @@ def make_list(size):
6666

6767
ll = make_list(100000)
6868
assert ll[-1] == 99999
69+
70+
ll = [i for i in range(0, 1, 2)]
71+
assert ll == [0], "expected '[0]' but was '%r'" % ll
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
*PyBytesIOTest.test_issue5449
22
*PyBytesIOTest.test_read1
3-
*PyBytesIOTest.test_readinto
43
*PyBytesIOTest.test_relative_seek
54
*PyBytesIOTest.test_unicode

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
*OperatorPickleTestCase.test_attrgetter
22
*OperatorPickleTestCase.test_itemgetter
3-
*OperatorPickleTestCase.test_methodcaller
43
*OperatorTestCase.test_abs
54
*OperatorTestCase.test_add
65
*OperatorTestCase.test_attrgetter
@@ -27,7 +26,6 @@
2726
*OperatorTestCase.test_lshift
2827
*OperatorTestCase.test_lt
2928
*OperatorTestCase.test_matmul
30-
*OperatorTestCase.test_methodcaller
3129
*OperatorTestCase.test_mod
3230
*OperatorTestCase.test_mul
3331
*OperatorTestCase.test_ne

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@
33
*ConversionErrorTest.test_pack_int
44
*ConversionErrorTest.test_pack_uint
55
*ConversionErrorTest.test_uhyper
6-
*XDRTest.test_xdr

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/PythonLanguage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ public static Source newSource(PythonContext ctxt, String src, String name, bool
474474
}
475475
return newSource(ctxt, sourceBuilder);
476476
} catch (IOException e) {
477-
throw new AssertionError();
477+
throw new IllegalStateException(e);
478478
}
479479
}
480480

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/Python3Core.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@
132132
import com.oracle.graal.python.builtins.objects.list.ListBuiltins;
133133
import com.oracle.graal.python.builtins.objects.lzma.LZMACompressorBuiltins;
134134
import com.oracle.graal.python.builtins.objects.lzma.LZMADecompressorBuiltins;
135+
import com.oracle.graal.python.builtins.objects.map.MapBuiltins;
135136
import com.oracle.graal.python.builtins.objects.mappingproxy.MappingproxyBuiltins;
136137
import com.oracle.graal.python.builtins.objects.memoryview.BufferBuiltins;
137138
import com.oracle.graal.python.builtins.objects.memoryview.MemoryviewBuiltins;
@@ -328,6 +329,7 @@ private static final PythonBuiltins[] initializeBuiltins() {
328329
new ReversedBuiltins(),
329330
new PZipBuiltins(),
330331
new EnumerateBuiltins(),
332+
new MapBuiltins(),
331333
new SentinelIteratorBuiltins(),
332334
new ForeignIteratorBuiltins(),
333335
new GeneratorBuiltins(),
@@ -585,9 +587,9 @@ private void initializeTypes() {
585587
}
586588
}
587589
// now initialize well-known objects
588-
pyTrue = new PInt(PythonBuiltinClassType.Boolean, BigInteger.ONE);
589-
pyFalse = new PInt(PythonBuiltinClassType.Boolean, BigInteger.ZERO);
590-
pyNaN = new PFloat(PythonBuiltinClassType.PFloat, Double.NaN);
590+
pyTrue = PythonObjectFactory.getUncached().createInt(PythonBuiltinClassType.Boolean, BigInteger.ONE);
591+
pyFalse = PythonObjectFactory.getUncached().createInt(PythonBuiltinClassType.Boolean, BigInteger.ZERO);
592+
pyNaN = PythonObjectFactory.getUncached().createFloat(Double.NaN);
591593
}
592594

593595
private void populateBuiltins() {

0 commit comments

Comments
 (0)