Skip to content

Commit 322ae3c

Browse files
committed
[GR-25464] [GR-23214] [GR-23232] [GR-23205] Update less important tests and changelog for the release
PullRequest: graalpython/1343
2 parents d662648 + 8a38175 commit 322ae3c

File tree

14 files changed

+261
-160
lines changed

14 files changed

+261
-160
lines changed

.mx_vcs_root

Whitespace-only changes.

CHANGELOG.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,23 @@
33
This changelog summarizes major changes between GraalVM versions of the Python
44
language runtime. The main focus is on user-observable behavior of the engine.
55

6+
## Version 20.3.0
7+
8+
* Fix multiple memory leaks when running Python code in a shared engine.
9+
* Update language support target and standard library to 3.8.5
10+
* Hide internal catching frames from tracebacks
11+
* Update HPy support to the latest version with support for piconumpy
12+
* Many fixes to pass the unittests of standard library types and modules:
13+
complex, bytes, bytearray, subclassing of special descriptors, type layouts,
14+
float, generators, modules, argument passing corner cases, string literals and
15+
encodings, import and importlib, decimal, glob, the builtin module, json,
16+
math, operator, numeric tower, sys, warnings, random, f-strings, struct,
17+
itertools
18+
619
## Version 20.2.0
720

8-
* Escaping Unicode characters using the character names in strings like "\N{GREEK CAPITAL LETTER DELTA}".
21+
* Escaping Unicode characters using the character names in strings like
22+
"\N{GREEK CAPITAL LETTER DELTA}".
923
* When a `*.py` file is imported, `*.pyc` file is created. It contains binary data to speed up parsing.
1024
* Adding option `PyCachePrefix`, which is equivalent to PYTHONPYCACHEPREFIX environment variable, which is also accepted now.
1125
* Adding optin `DontWriteBytecodeFlag`. Equivalent to the Python -B flag. Don't write bytecode files.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*graalpython.lib-python.3.test.test_descrtut.TestMain.test_main

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

Lines changed: 41 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import java.lang.management.ManagementFactory;
3030
import java.util.List;
3131

32+
import com.oracle.graal.python.PythonLanguage;
3233
import com.oracle.graal.python.builtins.Builtin;
3334
import com.oracle.graal.python.builtins.CoreFunctions;
3435
import com.oracle.graal.python.builtins.PythonBuiltins;
@@ -38,8 +39,12 @@
3839
import com.oracle.graal.python.builtins.objects.list.PList;
3940
import com.oracle.graal.python.builtins.objects.tuple.PTuple;
4041
import com.oracle.graal.python.nodes.function.PythonBuiltinNode;
42+
import com.oracle.graal.python.runtime.PythonContext;
43+
import com.oracle.graal.python.runtime.PythonCore;
44+
import com.oracle.graal.python.util.PythonUtils;
4145
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
4246
import com.oracle.truffle.api.dsl.Cached;
47+
import com.oracle.truffle.api.dsl.CachedContext;
4348
import com.oracle.truffle.api.dsl.Fallback;
4449
import com.oracle.truffle.api.dsl.GenerateNodeFactory;
4550
import com.oracle.truffle.api.dsl.Specialization;
@@ -54,48 +59,70 @@ protected List<com.oracle.truffle.api.dsl.NodeFactory<? extends PythonBuiltinNod
5459
return GcModuleBuiltinsFactory.getFactories();
5560
}
5661

62+
@Override
63+
public void initialize(PythonCore core) {
64+
builtinConstants.put("DEBUG_LEAK", 0);
65+
super.initialize(core);
66+
}
67+
5768
@Builtin(name = "collect", minNumOfPositionalArgs = 0, maxNumOfPositionalArgs = 1)
5869
@GenerateNodeFactory
5970
abstract static class GcCollectNode extends PythonBuiltinNode {
6071
@Specialization
6172
int collect(VirtualFrame frame, @SuppressWarnings("unused") Object level,
6273
@Cached BranchProfile asyncProfile) {
63-
doGc();
74+
PythonUtils.forceFullGC();
6475
// collect some weak references now
6576
getContext().triggerAsyncActions(frame, asyncProfile);
6677
return 0;
6778
}
68-
69-
@TruffleBoundary
70-
private static void doGc() {
71-
System.gc();
72-
}
7379
}
7480

7581
@Builtin(name = "isenabled", minNumOfPositionalArgs = 0)
7682
@GenerateNodeFactory
7783
abstract static class GcIsEnabledNode extends PythonBuiltinNode {
7884
@Specialization
79-
boolean isenabled() {
80-
return true;
85+
boolean isenabled(@CachedContext(PythonLanguage.class) PythonContext ctx) {
86+
return ctx.isGcEnabled();
8187
}
8288
}
8389

84-
abstract static class StubNode extends PythonBuiltinNode {
90+
@Builtin(name = "disable", minNumOfPositionalArgs = 0)
91+
@GenerateNodeFactory
92+
abstract static class DisableNode extends PythonBuiltinNode {
8593
@Specialization
86-
PNone disable() {
94+
PNone disable(@CachedContext(PythonLanguage.class) PythonContext ctx) {
95+
ctx.setGcEnabled(false);
8796
return PNone.NONE;
8897
}
8998
}
9099

91-
@Builtin(name = "disable", minNumOfPositionalArgs = 0)
100+
@Builtin(name = "enable", minNumOfPositionalArgs = 0)
101+
@GenerateNodeFactory
102+
abstract static class EnableNode extends PythonBuiltinNode {
103+
@Specialization
104+
PNone enable(@CachedContext(PythonLanguage.class) PythonContext ctx) {
105+
ctx.setGcEnabled(true);
106+
return PNone.NONE;
107+
}
108+
}
109+
110+
@Builtin(name = "get_debug", minNumOfPositionalArgs = 0)
92111
@GenerateNodeFactory
93-
abstract static class DisableNode extends StubNode {
112+
abstract static class GetDebugNode extends PythonBuiltinNode {
113+
@Specialization
114+
int getDebug() {
115+
return 0;
116+
}
94117
}
95118

96-
@Builtin(name = "enable", minNumOfPositionalArgs = 0)
119+
@Builtin(name = "set_debug", minNumOfPositionalArgs = 1)
97120
@GenerateNodeFactory
98-
abstract static class EnableNode extends StubNode {
121+
abstract static class SetDebugNode extends PythonBuiltinNode {
122+
@Specialization
123+
PNone setDebug(@SuppressWarnings("unused") Object ignored) {
124+
return PNone.NONE;
125+
}
99126
}
100127

101128
@Builtin(name = "get_count", minNumOfPositionalArgs = 0)

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
import com.oracle.graal.python.nodes.function.PythonBuiltinNode;
6767
import com.oracle.graal.python.nodes.object.IsBuiltinClassProfile;
6868
import com.oracle.graal.python.runtime.AsyncHandler;
69+
import com.oracle.graal.python.runtime.PythonContext;
6970
import com.oracle.graal.python.runtime.PythonCore;
7071
import com.oracle.graal.python.runtime.exception.PythonErrorType;
7172
import com.oracle.truffle.api.CompilerDirectives;
@@ -111,8 +112,11 @@ public void postInitialize(PythonCore core) {
111112
PythonModule weakrefModule = core.lookupBuiltinModule("_weakref");
112113
weakrefModule.setAttribute(weakRefQueueKey, weakRefQueue);
113114
core.lookupType(PythonBuiltinClassType.PReferenceType).setAttribute(weakRefQueueKey, weakRefQueue);
114-
115+
final PythonContext ctx = core.getContext();
115116
core.getContext().registerAsyncAction(() -> {
117+
if (!ctx.isGcEnabled()) {
118+
return null;
119+
}
116120
Reference<? extends Object> reference = null;
117121
try {
118122
reference = weakRefQueue.remove();

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/BytesBuiltins.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ public abstract static class AddNode extends PythonBinaryBuiltinNode {
387387

388388
@Specialization
389389
public PBytesLike add(PBytesLike self, PBytesLike other,
390-
@Cached SequenceStorageNodes.ConcatNode concatNode,
390+
@Cached("createWithOverflowError()") SequenceStorageNodes.ConcatNode concatNode,
391391
@Cached BytesNodes.CreateBytesNode create) {
392392
SequenceStorage res = concatNode.execute(self.getSequenceStorage(), other.getSequenceStorage());
393393
return create.execute(factory(), self, res);
@@ -396,7 +396,7 @@ public PBytesLike add(PBytesLike self, PBytesLike other,
396396
@Specialization(guards = "bufferLib.isBuffer(buffer)", limit = "3")
397397
public PBytesLike add(PBytesLike self, Object buffer,
398398
@CachedLibrary("buffer") PythonObjectLibrary bufferLib,
399-
@Cached("create()") SequenceStorageNodes.ConcatNode concatNode,
399+
@Cached("createWithOverflowError()") SequenceStorageNodes.ConcatNode concatNode,
400400
@Cached BytesNodes.CreateBytesNode create) {
401401
try {
402402
byte[] bytes = bufferLib.getBufferBytes(buffer);
@@ -419,7 +419,7 @@ public Object add(Object self, Object other) {
419419
public abstract static class MulNode extends PythonBinaryBuiltinNode {
420420
@Specialization
421421
public PBytesLike mul(VirtualFrame frame, PBytesLike self, int times,
422-
@Cached("create()") SequenceStorageNodes.RepeatNode repeatNode,
422+
@Cached("createWithOverflowError()") SequenceStorageNodes.RepeatNode repeatNode,
423423
@Cached BytesNodes.CreateBytesNode create) {
424424
SequenceStorage res = repeatNode.execute(frame, self.getSequenceStorage(), times);
425425
return create.execute(factory(), self, res);
@@ -428,7 +428,7 @@ public PBytesLike mul(VirtualFrame frame, PBytesLike self, int times,
428428
@Specialization(limit = "getCallSiteInlineCacheMaxDepth()")
429429
public PBytesLike mul(VirtualFrame frame, PBytesLike self, Object times,
430430
@Cached("createBinaryProfile()") ConditionProfile hasFrame,
431-
@Cached("create()") SequenceStorageNodes.RepeatNode repeatNode,
431+
@Cached("createWithOverflowError()") SequenceStorageNodes.RepeatNode repeatNode,
432432
@Cached BytesNodes.CreateBytesNode create,
433433
@CachedLibrary("times") PythonObjectLibrary lib) {
434434
SequenceStorage res = repeatNode.execute(frame, self.getSequenceStorage(), getTimesInt(frame, times, hasFrame, lib));

0 commit comments

Comments
 (0)