Skip to content

Commit 3435642

Browse files
committed
[GR-35949][GR-34610] Fixes for np.ndindex and pytz
PullRequest: graalpython/2087
2 parents 99d48d5 + 71eaf55 commit 3435642

File tree

4 files changed

+26
-2
lines changed

4 files changed

+26
-2
lines changed

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,19 @@ def compile_module(self, name):
214214
cmpfunc=unhandled_error_compare
215215
)
216216

217+
test_PyUnicode_FromFormat_c = CPyExtFunction(
218+
_reference_fromformat,
219+
lambda: (
220+
("char %c\n", ord('x')),
221+
("char %c\n", ord('あ')),
222+
),
223+
resultspec="O",
224+
argspec='si',
225+
arguments=["char* fmt", "int c"],
226+
callfunction="PyUnicode_FromFormat",
227+
cmpfunc=unhandled_error_compare
228+
)
229+
217230
test_PyUnicode_FromFormat4 = CPyExtFunction(
218231
_reference_fromformat,
219232
lambda: (

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,11 @@ def test_inputtypes(self):
3737
def test_baddecorator(self):
3838
data = 'The quick Brown fox Jumped over The lazy Dog'.split()
3939
self.assertRaises(TypeError, sorted, data, None, lambda x,y: 0)
40+
41+
def test_list_subclass(self):
42+
class MyList(list):
43+
def __iter__(self):
44+
return iter([4, 2, 5])
45+
46+
# Use eval to get the fast path specialization
47+
self.assertEqual(eval("sorted(MyList())", {"MyList": MyList}), [2, 4, 5])

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/CExtNodes.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@
9696
import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodesFactory.TransformExceptionToNativeNodeGen;
9797
import com.oracle.graal.python.builtins.objects.cext.capi.CExtNodesFactory.VoidPtrToJavaNodeGen;
9898
import com.oracle.graal.python.builtins.objects.cext.capi.DynamicObjectNativeWrapper.PrimitiveNativeWrapper;
99-
import com.oracle.graal.python.builtins.objects.cext.capi.DynamicObjectNativeWrapper.PythonObjectNativeWrapper;
10099
import com.oracle.graal.python.builtins.objects.cext.capi.DynamicObjectNativeWrapper.WriteNativeMemberNode;
101100
import com.oracle.graal.python.builtins.objects.cext.capi.ExternalFunctionNodes.DefaultCheckFunctionResultNode;
102101
import com.oracle.graal.python.builtins.objects.cext.capi.ExternalFunctionNodes.MethKeywordsRoot;
@@ -107,6 +106,7 @@
107106
import com.oracle.graal.python.builtins.objects.cext.capi.NativeReferenceCache.ResolveNativeReferenceNode;
108107
import com.oracle.graal.python.builtins.objects.cext.capi.PGetDynamicTypeNode.GetSulongTypeNode;
109108
import com.oracle.graal.python.builtins.objects.cext.capi.PyTruffleObjectFree.FreeNode;
109+
import com.oracle.graal.python.builtins.objects.cext.capi.DynamicObjectNativeWrapper.PythonObjectNativeWrapper;
110110
import com.oracle.graal.python.builtins.objects.cext.common.CArrayWrappers.CArrayWrapper;
111111
import com.oracle.graal.python.builtins.objects.cext.common.CArrayWrappers.CByteArrayWrapper;
112112
import com.oracle.graal.python.builtins.objects.cext.common.CArrayWrappers.CStringWrapper;
@@ -3367,6 +3367,8 @@ Object doGeneric(String format, Object vaList) {
33673367
throw raiseNode.raise(PythonBuiltinClassType.OverflowError, "character argument not in range(0x110000)");
33683368
}
33693369
result.append((char) ordinal);
3370+
vaArgIdx++;
3371+
valid = true;
33703372
break;
33713373
case 'd':
33723374
case 'i':

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/builtins/ListNodes.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,10 @@ static PList none(Object cls, @SuppressWarnings("unused") PNone none,
114114
return factory.createList(cls);
115115
}
116116

117-
@Specialization
117+
@Specialization(guards = "cannotBeOverridden(list, getClassNode)", limit = "1")
118118
// Don't use PSequence, that might copy storages that we don't allow for lists
119119
static PList fromList(Object cls, PList list,
120+
@SuppressWarnings("unused") @Cached GetClassNode getClassNode,
120121
@Shared("factory") @Cached PythonObjectFactory factory,
121122
@Cached SequenceNodes.GetSequenceStorageNode getSequenceStorageNode,
122123
@Cached SequenceStorageNodes.CopyNode copyNode) {

0 commit comments

Comments
 (0)