Skip to content

Commit a78ccd3

Browse files
committed
Merge branch 'msimacek/GR-50471_fix_poetry' into msimacek/GR-50050_unittest_assertions
2 parents 885dd01 + bb169e9 commit a78ccd3

File tree

8 files changed

+49
-37
lines changed

8 files changed

+49
-37
lines changed

graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test/builtin/modules/FileDescriptorConversionNodeTests.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,6 @@ public void none() {
7676
Assert.assertEquals(AT_FDCWD.value, call(PNone.NO_VALUE));
7777
}
7878

79-
@Test
80-
public void noValue() {
81-
expectPythonMessage("TypeError: argument must be an int, or have a fileno() method.");
82-
call(PNone.NO_VALUE);
83-
}
84-
8579
@Test
8680
public void fdBool() {
8781
Assert.assertEquals(0, call(false));

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,8 @@ def test_descr_call_with_none():
179179
descr = object.__dict__['__class__']
180180
assert None.__class__ is type(None)
181181
assert descr.__get__(None, type(None)) is descr
182+
assert None.__repr__() == 'None'
183+
assert None.__bool__() is False
182184
assert_raises(TypeError, descr.__get__, None, None)
183185

184186
def test_custom_getattribute():
@@ -224,4 +226,4 @@ def __getattribute__(self, name):
224226
return super().__getattribute__(name)
225227

226228
d = {"abc": 1}
227-
assert dict(BBB(d)) == d
229+
assert dict(BBB(d)) == d

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import com.oracle.graal.python.builtins.CoreFunctions;
3434
import com.oracle.graal.python.builtins.PythonBuiltinClassType;
3535
import com.oracle.graal.python.builtins.PythonBuiltins;
36+
import com.oracle.graal.python.builtins.objects.PNone;
3637
import com.oracle.graal.python.builtins.objects.random.PRandom;
3738
import com.oracle.graal.python.nodes.call.special.LookupAndCallBinaryNode;
3839
import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
@@ -65,7 +66,7 @@ abstract static class PRandomNode extends PythonBuiltinNode {
6566
PRandom random(VirtualFrame frame, Object cls, Object seed,
6667
@Cached PythonObjectFactory factory) {
6768
PRandom random = factory.createRandom(cls);
68-
setSeed.executeObject(frame, random, seed);
69+
setSeed.executeObject(frame, random, seed != PNone.NO_VALUE ? seed : PNone.NONE);
6970
return random;
7071
}
7172
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/NoneBuiltins.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@
5252
import com.oracle.graal.python.builtins.CoreFunctions;
5353
import com.oracle.graal.python.builtins.PythonBuiltinClassType;
5454
import com.oracle.graal.python.builtins.PythonBuiltins;
55+
import com.oracle.graal.python.builtins.objects.function.PBuiltinFunction;
5556
import com.oracle.graal.python.builtins.objects.getsetdescriptor.GetSetDescriptor;
57+
import com.oracle.graal.python.builtins.objects.object.ObjectBuiltins;
5658
import com.oracle.graal.python.nodes.ErrorMessages;
5759
import com.oracle.graal.python.nodes.PRaiseNode;
5860
import com.oracle.graal.python.nodes.attributes.LookupAttributeInMRONode;
@@ -62,6 +64,7 @@
6264
import com.oracle.graal.python.nodes.function.builtins.PythonUnaryBuiltinNode;
6365
import com.oracle.graal.python.nodes.util.CannotCastException;
6466
import com.oracle.graal.python.nodes.util.CastToTruffleStringNode;
67+
import com.oracle.graal.python.runtime.object.PythonObjectFactory;
6568
import com.oracle.truffle.api.dsl.Bind;
6669
import com.oracle.truffle.api.dsl.Cached;
6770
import com.oracle.truffle.api.dsl.GenerateNodeFactory;
@@ -120,7 +123,10 @@ static Object doIt(VirtualFrame frame, Object object, Object keyObj,
120123
@Cached LookupAttributeInMRONode.Dynamic lookup,
121124
@Cached CallUnaryMethodNode callGet,
122125
@Cached CastToTruffleStringNode castKeyToStringNode,
126+
@Cached PythonObjectFactory.Lazy factory,
127+
@Cached ObjectBuiltins.GetAttributeNode getAttributeNode,
123128
@Cached PRaiseNode.Lazy raiseNode) {
129+
assert object == PNone.NONE;
124130
TruffleString key;
125131
try {
126132
key = castKeyToStringNode.execute(inliningTarget, keyObj);
@@ -130,14 +136,20 @@ static Object doIt(VirtualFrame frame, Object object, Object keyObj,
130136

131137
Object descr = lookup.execute(PythonBuiltinClassType.PNone, key);
132138
if (descr == PNone.NO_VALUE) {
133-
throw raiseNode.get(inliningTarget).raise(AttributeError, ErrorMessages.OBJ_P_HAS_NO_ATTR_S, object, key);
139+
throw raiseNode.get(inliningTarget).raise(AttributeError, ErrorMessages.OBJ_P_HAS_NO_ATTR_S, PNone.NONE, key);
134140
}
135141
if (descr instanceof GetSetDescriptor getSetDescriptor) {
136142
// Bypass getset_descriptor.__get__
137143
assert getSetDescriptor.getGet() != null;
138-
return callGet.executeObject(frame, getSetDescriptor.getGet(), object);
144+
return callGet.executeObject(frame, getSetDescriptor.getGet(), PNone.NONE);
139145
}
140-
return descr;
146+
if (descr instanceof PBuiltinFunction function) {
147+
// Bypass method_descriptor.__get__
148+
assert !function.needsDeclaringType();
149+
return factory.get(inliningTarget).createBuiltinMethod(PNone.NONE, function);
150+
}
151+
// Delegate classmethods, staticmethods etc. to object.__getattribute__
152+
return getAttributeNode.execute(frame, PNone.NONE, key);
141153
}
142154
}
143155
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/dict/DictViewBuiltins.java

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -492,19 +492,7 @@ static PBaseSet doItemsView(VirtualFrame frame, PDictItemsView self, PBaseSet ot
492492
}
493493

494494
@Specialization
495-
static PBaseSet doNotIterable(VirtualFrame frame, PDictItemsView self, PDictItemsView other,
496-
@Bind("this") Node inliningTarget,
497-
@Shared("constrSet") @Cached SetNodes.ConstructSetNode constructSetNode,
498-
@Shared("diff") @Cached HashingStorageDiff diffNode,
499-
@Shared @Cached PythonObjectFactory factory) {
500-
PSet selfSet = constructSetNode.executeWith(frame, self);
501-
PSet otherSet = constructSetNode.executeWith(frame, other);
502-
HashingStorage storage = diffNode.execute(frame, inliningTarget, selfSet.getDictStorage(), otherSet.getDictStorage());
503-
return factory.createSet(storage);
504-
}
505-
506-
@Specialization
507-
static PBaseSet doItemsView(VirtualFrame frame, PDictItemsView self, Object other,
495+
static PBaseSet doGeneric(VirtualFrame frame, Object self, Object other,
508496
@Bind("this") Node inliningTarget,
509497
@Shared("constrSet") @Cached SetNodes.ConstructSetNode constructSetNode,
510498
@Shared("diff") @Cached HashingStorageDiff diffNode,

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/object/ObjectBuiltins.java

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -432,11 +432,10 @@ Object doItTruffleString(VirtualFrame frame, Object object, @SuppressWarnings("u
432432
@SuppressWarnings("unused") @Cached("keyObj") TruffleString cachedKey,
433433
@Exclusive @Cached GetClassNode getClassNode,
434434
@Cached("create(cachedKey)") LookupAttributeInMRONode lookup,
435-
@Exclusive @Cached PythonObjectFactory.Lazy factory,
436435
@Exclusive @Cached PRaiseNode.Lazy raiseNode) {
437436
Object type = getClassNode.execute(inliningTarget, object);
438437
Object descr = lookup.execute(type);
439-
return fullLookup(frame, inliningTarget, object, cachedKey, type, descr, factory, raiseNode);
438+
return fullLookup(frame, inliningTarget, object, cachedKey, type, descr, raiseNode);
440439
}
441440

442441
@Specialization
@@ -446,7 +445,6 @@ Object doIt(VirtualFrame frame, Object object, Object keyObj,
446445
@Cached LookupAttributeInMRONode.Dynamic lookup,
447446
@Exclusive @Cached GetClassNode getClassNode,
448447
@Cached CastToTruffleStringNode castKeyToStringNode,
449-
@Exclusive @Cached PythonObjectFactory.Lazy factory,
450448
@Exclusive @Cached PRaiseNode.Lazy raiseNode) {
451449
TruffleString key;
452450
try {
@@ -457,10 +455,10 @@ Object doIt(VirtualFrame frame, Object object, Object keyObj,
457455

458456
Object type = getClassNode.execute(inliningTarget, object);
459457
Object descr = lookup.execute(type, key);
460-
return fullLookup(frame, inliningTarget, object, key, type, descr, factory, raiseNode);
458+
return fullLookup(frame, inliningTarget, object, key, type, descr, raiseNode);
461459
}
462460

463-
private Object fullLookup(VirtualFrame frame, Node inliningTarget, Object object, TruffleString key, Object type, Object descr, PythonObjectFactory.Lazy factory, PRaiseNode.Lazy raiseNode) {
461+
private Object fullLookup(VirtualFrame frame, Node inliningTarget, Object object, TruffleString key, Object type, Object descr, PRaiseNode.Lazy raiseNode) {
464462
Object dataDescClass = null;
465463
boolean hasDescr = descr != PNone.NO_VALUE;
466464
if (hasDescr && (profileFlags & HAS_DESCR) == 0) {
@@ -501,14 +499,6 @@ private Object fullLookup(VirtualFrame frame, Node inliningTarget, Object object
501499
profileFlags |= HAS_NO_VALUE;
502500
}
503501
if (hasDescr) {
504-
if (object == PNone.NONE) {
505-
if (descr instanceof PBuiltinFunction) {
506-
// Special case for None object. We cannot call function.__get__(None,
507-
// type(None)),
508-
// because that would return an unbound method
509-
return factory.get(inliningTarget).createBuiltinMethod(PNone.NONE, (PBuiltinFunction) descr);
510-
}
511-
}
512502
Object get = lookupGet(dataDescClass);
513503
if (get == PNone.NO_VALUE) {
514504
return descr;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[[rules]]
2+
patch = 'rapidfuzz.patch'
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
diff --git a/setup.py b/setup.py
2+
index dcfa932..260376d 100644
3+
--- a/setup.py
4+
+++ b/setup.py
5+
@@ -1,6 +1,7 @@
6+
from __future__ import annotations
7+
8+
import os
9+
+import sys
10+
11+
12+
def show_message(*lines):
13+
@@ -69,7 +70,9 @@ packaging = "1" in {
14+
os.environ.get("PIWHEELS_BUILD", "0"),
15+
os.environ.get("RAPIDFUZZ_BUILD_EXTENSION", "0"),
16+
}
17+
-if packaging:
18+
+if sys.implementation.name == 'graalpy':
19+
+ run_setup(False)
20+
+elif packaging:
21+
run_setup(True)
22+
else:
23+
try:

0 commit comments

Comments
 (0)