Skip to content

Commit e329f82

Browse files
committed
Merge remote-tracking branch 'origin/master' into tim/numpy-building
2 parents 615feb7 + 08dfee5 commit e329f82

File tree

26 files changed

+639
-56
lines changed

26 files changed

+639
-56
lines changed

graalpython/com.oracle.graal.python.cext/include/pyfpe.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
1-
#ifndef Py_PYFPE_H
2-
#define Py_PYFPE_H
3-
#ifdef __cplusplus
4-
extern "C" {
5-
#endif
61
/*
72
---------------------------------------------------------------------
8-
/ Copyright (c) 1996. \
3+
/ Copyright (c) 1996, 2018. \
94
| The Regents of the University of California. |
105
| All rights reserved. |
116
| |
@@ -41,6 +36,11 @@ extern "C" {
4136
---------------------------------------------------------------------
4237
*/
4338

39+
#ifndef Py_PYFPE_H
40+
#define Py_PYFPE_H
41+
#ifdef __cplusplus
42+
extern "C" {
43+
#endif
4444
/*
4545
* Define macros for handling SIGFPE.
4646
* Lee Busby, LLNL, November, 1996
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright (c) 2018, Oracle and/or its affiliates.
3+
*
4+
* The Universal Permissive License (UPL), Version 1.0
5+
*
6+
* Subject to the condition set forth below, permission is hereby granted to any
7+
* person obtaining a copy of this software, associated documentation and/or data
8+
* (collectively the "Software"), free of charge and under any and all copyright
9+
* rights in the Software, and any and all patent rights owned or freely
10+
* licensable by each licensor hereunder covering either (i) the unmodified
11+
* Software as contributed to or provided by such licensor, or (ii) the Larger
12+
* Works (as defined below), to deal in both
13+
*
14+
* (a) the Software, and
15+
* (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
16+
* one is included with the Software (each a "Larger Work" to which the
17+
* Software is contributed by such licensors),
18+
*
19+
* without restriction, including without limitation the rights to copy, create
20+
* derivative works of, display, perform, and distribute the Software and make,
21+
* use, sell, offer for sale, import, export, have made, and have sold the
22+
* Software and the Larger Work(s), and to sublicense the foregoing rights on
23+
* either these or other terms.
24+
*
25+
* This license is subject to the following condition:
26+
*
27+
* The above copyright notice and either this complete permission notice or at a
28+
* minimum a reference to the UPL must be included in all copies or substantial
29+
* portions of the Software.
30+
*
31+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
32+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
33+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
34+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
35+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
36+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
37+
* SOFTWARE.
38+
*/
39+
#include "capi.h"
40+
41+
#ifndef Py_DEFAULT_RECURSION_LIMIT
42+
#define Py_DEFAULT_RECURSION_LIMIT 1000
43+
#endif
44+
int _Py_CheckRecursionLimit = Py_DEFAULT_RECURSION_LIMIT;
45+

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ public static void main(String[] args) {
6565
private String commandString = null;
6666
private String inputFile = null;
6767
private boolean inspectFlag = false;
68+
private boolean verboseFlag = false;
6869
private boolean runCC = false;
6970
private boolean runLD = false;
7071
private VersionAction versionAction = VersionAction.None;
@@ -81,6 +82,9 @@ protected List<String> preprocessArguments(List<String> arguments, Map<String, S
8182
case "-B":
8283
System.out.println("Warning: " + arg + " does nothing on GraalPython.");
8384
break;
85+
case "-v":
86+
verboseFlag = true;
87+
break;
8488
case "-V":
8589
case "--version":
8690
versionAction = VersionAction.PrintAndExit;
@@ -160,7 +164,10 @@ protected void launch(Builder contextBuilder) {
160164
// to print Python exceptions
161165
contextBuilder.option("python.AlwaysRunExcepthook", "true");
162166
if (inspectFlag) {
163-
contextBuilder.option("python.PythonInspectFlag", "true");
167+
contextBuilder.option("python.InspectFlag", "true");
168+
}
169+
if (verboseFlag) {
170+
contextBuilder.option("python.VerboseFlag", "true");
164171
}
165172

166173
ConsoleHandler consoleHandler = createConsoleHandler(System.in, System.out);

graalpython/com.oracle.graal.python.tck/src/com/oracle/graal/python/tck/PythonProvider.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,18 @@
3939
package com.oracle.graal.python.tck;
4040

4141
import static org.graalvm.polyglot.tck.TypeDescriptor.ANY;
42+
import static org.graalvm.polyglot.tck.TypeDescriptor.ARRAY;
4243
import static org.graalvm.polyglot.tck.TypeDescriptor.BOOLEAN;
44+
import static org.graalvm.polyglot.tck.TypeDescriptor.EXECUTABLE;
45+
import static org.graalvm.polyglot.tck.TypeDescriptor.HOST_OBJECT;
46+
import static org.graalvm.polyglot.tck.TypeDescriptor.NATIVE_POINTER;
4347
import static org.graalvm.polyglot.tck.TypeDescriptor.NULL;
4448
import static org.graalvm.polyglot.tck.TypeDescriptor.NUMBER;
4549
import static org.graalvm.polyglot.tck.TypeDescriptor.OBJECT;
4650
import static org.graalvm.polyglot.tck.TypeDescriptor.STRING;
4751
import static org.graalvm.polyglot.tck.TypeDescriptor.array;
4852
import static org.graalvm.polyglot.tck.TypeDescriptor.executable;
53+
import static org.graalvm.polyglot.tck.TypeDescriptor.intersection;
4954
import static org.graalvm.polyglot.tck.TypeDescriptor.union;
5055

5156
import java.io.IOException;
@@ -100,6 +105,8 @@ private static void addStatementSnippet(Context context, List<Snippet> snippets,
100105

101106
public Collection<? extends Snippet> createValueConstructors(Context context) {
102107
List<Snippet> snippets = new ArrayList<>();
108+
final TypeDescriptor noType = intersection();
109+
final TypeDescriptor allTypes = intersection(noType, NULL, BOOLEAN, NUMBER, STRING, HOST_OBJECT, NATIVE_POINTER, OBJECT, ARRAY, EXECUTABLE);
103110
// @formatter:off
104111
addValueSnippet(context, snippets, "BooleanType:True", BOOLEAN, "lambda: True");
105112
addValueSnippet(context, snippets, "BooleanType:False", BOOLEAN, "lambda: False");
@@ -108,11 +115,11 @@ public Collection<? extends Snippet> createValueConstructors(Context context) {
108115
addValueSnippet(context, snippets, "FloatType", NUMBER, "lambda: 1.1");
109116
addValueSnippet(context, snippets, "ComplexType", OBJECT, "lambda: 1.0j");
110117
addValueSnippet(context, snippets, "StringType", STRING, "lambda: 'spam'");
111-
addValueSnippet(context, snippets, "TupleType:Empty", array(NULL), "lambda: ()");
118+
addValueSnippet(context, snippets, "TupleType:Empty", array(allTypes), "lambda: ()");
112119
addValueSnippet(context, snippets, "TupleType:Number", array(NUMBER), "lambda: (1, 2.1)");
113120
addValueSnippet(context, snippets, "TupleType:String", array(STRING), "lambda: ('foo', 'bar')");
114121
addValueSnippet(context, snippets, "TupleType:Mixed", array(union(NUMBER, STRING)), "lambda: ('foo', 1)");
115-
addValueSnippet(context, snippets, "ListType:Empty", array(NULL), "lambda: []");
122+
addValueSnippet(context, snippets, "ListType:Empty", array(allTypes), "lambda: []");
116123
addValueSnippet(context, snippets, "ListType:Number", array(NUMBER), "lambda: [1, 2.1]");
117124
addValueSnippet(context, snippets, "ListType:String", array(STRING), "lambda: ['foo', 'bar']");
118125
addValueSnippet(context, snippets, "ListType:Mixed", array(union(NUMBER, STRING)), "lambda: ['foo', 1]");

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ def compile_module(self, name):
219219
),
220220
resultspec="O",
221221
argspec='n',
222-
arguments=["Py_ssize_t n"],
222+
arguments=["void* ptr"],
223223
cmpfunc=unhandled_error_compare
224224
)
225225

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import sys
1010
import os
11-
#from functools import cmp_to_key
11+
from functools import cmp_to_key
1212
import seq_tests
1313
#from test import support
1414

@@ -489,8 +489,6 @@ def test_copy(self):
489489

490490
self.assertRaises(TypeError, u.copy, None)
491491

492-
# TODO cmp_to_key is not available yet
493-
'''
494492
def test_sort(self):
495493
u = self.type2test([1, 0])
496494
u.sort()
@@ -538,7 +536,6 @@ def selfmodifyingComparison(x,y):
538536
key=cmp_to_key(selfmodifyingComparison))
539537

540538
self.assertRaises(TypeError, z.sort, 42, 42, 42, 42)
541-
'''
542539

543540
def test_slice(self):
544541
u = self.type2test("spam")

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,3 +164,13 @@ def test_subclass_tuple():
164164

165165
assert issubclass(int, (int, (float, int)))
166166
assert issubclass(str, (str, (Child, str)))
167+
168+
169+
def test_abstract_numbers_issubclass():
170+
from numbers import Number, Integral, Complex, Real
171+
assert issubclass(int, Number)
172+
assert issubclass(int, Integral)
173+
assert issubclass(int, Complex)
174+
175+
assert not issubclass(complex, Real)
176+
assert issubclass(complex, Complex)

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,10 @@ def test_set_or():
5353

5454
union = s1 | s4
5555
assert union == {1, 2, 3}
56+
57+
58+
def test_set_remove():
59+
s = {1, 2, 3}
60+
assert s == {1, 2, 3}
61+
s.remove(3)
62+
assert s == {1, 2}

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

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
package com.oracle.graal.python;
2727

2828
import java.io.IOException;
29+
import java.text.MessageFormat;
2930
import java.util.ArrayList;
3031

3132
import org.graalvm.options.OptionDescriptors;
@@ -117,7 +118,13 @@ private static boolean optionsAllowPreInitializedContext(PythonContext context,
117118
// Verify that the option for using a shared core is the same as
118119
// at image building time
119120
final boolean useSharedCore = newEnv.getOptions().get(PythonOptions.SharedCore);
120-
return context.getCore().hasSingletonContext() == !useSharedCore;
121+
boolean canUsePreinitializedContext = context.getCore().hasSingletonContext() == !useSharedCore;
122+
if (canUsePreinitializedContext) {
123+
PythonCore.writeInfo(newEnv, "Using preinitialized context.");
124+
} else {
125+
PythonCore.writeInfo(newEnv, "Not using preinitialized context.");
126+
}
127+
return canUsePreinitializedContext;
121128
}
122129

123130
@Override
@@ -137,6 +144,12 @@ private void ensureHomeInOptions(Env env) {
137144
String coreHome = env.getOptions().get(PythonOptions.CoreHome);
138145
String stdLibHome = env.getOptions().get(PythonOptions.StdLibHome);
139146

147+
PythonCore.writeInfo(env, (MessageFormat.format("Initial locations:" +
148+
"\n\tLanguage home: {0}" +
149+
"\n\tSysPrefix: {1}" +
150+
"\n\tCoreHome: {2}" +
151+
"\n\tStdLibHome: {3}", languageHome, sysPrefix, coreHome, stdLibHome)));
152+
140153
TruffleFile home = null;
141154
if (languageHome != null) {
142155
home = env.getTruffleFile(languageHome);
@@ -187,6 +200,12 @@ private void ensureHomeInOptions(Env env) {
187200
}
188201
env.getOptions().set(PythonOptions.StdLibHome, stdLibHome);
189202
}
203+
204+
PythonCore.writeInfo(env, (MessageFormat.format("Updated locations:" +
205+
"\n\tLanguage home: {0}" +
206+
"\n\tSysPrefix: {1}" +
207+
"\n\tCoreHome: {2}" +
208+
"\n\tStdLibHome: {3}", home.getPath(), sysPrefix, coreHome, stdLibHome)));
190209
}
191210
}
192211

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -731,11 +731,6 @@ private boolean isInstanceCheckInternal(Object derived, Object cls) {
731731

732732
public abstract boolean executeWith(Object derived, Object cls);
733733

734-
@Specialization
735-
public boolean isSubclassType(Object derived, PythonClass cls) {
736-
return derived == cls || isSubtypeNode.execute(derived, cls);
737-
}
738-
739734
@Specialization(guards = "clsTuple.len() == cachedLen", limit = "getVariableArgumentInlineCacheLimit()")
740735
@ExplodeLoop
741736
public boolean isSubclassTupleConstantLen(Object derived, PTuple clsTuple,

0 commit comments

Comments
 (0)