Skip to content

Commit d5a9421

Browse files
author
Franziska Geiger
committed
Added test case
1 parent 5c288e3 commit d5a9421

File tree

2 files changed

+39
-3
lines changed

2 files changed

+39
-3
lines changed

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

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,3 +457,39 @@ def test_unhashable_key():
457457
assert_raises(TypeError, lambda: d[key_list])
458458
key_tuple_list = (key_list, 2)
459459
assert_raises(TypeError, lambda: d[key_tuple_list])
460+
461+
class EncodedString(str):
462+
# unicode string subclass to keep track of the original encoding.
463+
# 'encoding' is None for unicode strings and the source encoding
464+
# otherwise
465+
encoding = None
466+
467+
def __deepcopy__(self, memo):
468+
return self
469+
470+
def byteencode(self):
471+
assert self.encoding is not None
472+
return self.encode(self.encoding)
473+
474+
def utf8encode(self):
475+
assert self.encoding is None
476+
return self.encode("UTF-8")
477+
478+
@property
479+
def is_unicode(self):
480+
return self.encoding is None
481+
482+
def contains_surrogates(self):
483+
return string_contains_surrogates(self)
484+
485+
def as_utf8_string(self):
486+
return bytes_literal(self.utf8encode(), 'utf8')
487+
488+
489+
def test_wrapped_string_contains():
490+
testString = EncodedString('something')
491+
dict = {'something': (1, 0), 'nothing': (2, 0)}
492+
reached = False
493+
if testString in dict:
494+
reached = True
495+
assert reached

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/object/IsBuiltinClassProfile.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,9 @@ public boolean profileClass(LazyPythonClass clazz, PythonBuiltinClassType type)
206206
}
207207
}
208208

209-
public boolean profileClassWithBaseClasses(LazyPythonClass clazz, PythonBuiltinClassType type){
210-
if (!profileClass(clazz,type)) {
211-
PythonAbstractClass [] baseClasses = ((PythonClass) clazz).getBaseClasses();
209+
public boolean profileClassWithBaseClasses(LazyPythonClass clazz, PythonBuiltinClassType type) {
210+
if (!profileClass(clazz, type)) {
211+
PythonAbstractClass[] baseClasses = ((PythonClass) clazz).getBaseClasses();
212212
for (PythonAbstractClass baseClazz : baseClasses) {
213213
if (profileClass(baseClazz, type)) {
214214
return true;

0 commit comments

Comments
 (0)