Skip to content

Commit c25ee65

Browse files
committed
remove incorrect int.from_bytes with Strings
1 parent b76b045 commit c25ee65

File tree

3 files changed

+5
-20
lines changed
  • graalpython

3 files changed

+5
-20
lines changed

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -487,11 +487,10 @@ def test_wrong_input(self):
487487
self.assertRaises(TypeError, int.from_bytes, 0, 'big')
488488
self.assertRaises(TypeError, int.from_bytes, 0, 'big', True)
489489

490-
#TODO uncoment these tests, when GR-12453 is fixed
491-
#self.assertRaises(TypeError, int.from_bytes, "", 'big')
492-
#self.assertRaises(TypeError, int.from_bytes, "\x00", 'big')
493-
#self.assertRaises(TypeError, MyInt.from_bytes, "", 'big')
494-
#self.assertRaises(TypeError, MyInt.from_bytes, "\x00", 'big')
490+
self.assertRaises(TypeError, int.from_bytes, "", 'big')
491+
self.assertRaises(TypeError, int.from_bytes, "\x00", 'big')
492+
self.assertRaises(TypeError, MyInt.from_bytes, "", 'big')
493+
self.assertRaises(TypeError, MyInt.from_bytes, "\x00", 'big')
495494
self.assertRaises(TypeError, MyInt.from_bytes, 0, 'big')
496495
self.assertRaises(TypeError, int.from_bytes, 0, 'big', True)
497496

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints/IntBuiltins.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1981,20 +1981,6 @@ private Object compute(PythonClass cl, byte[] bytes, String byteorder, boolean s
19811981
return createIntObject(cl, bi);
19821982
}
19831983

1984-
// from String / PString
1985-
// TODO these specialization shouldn't be there. The CPython ends up with TypeError in such
1986-
// case. See GR-12453
1987-
@Specialization
1988-
@TruffleBoundary
1989-
public Object fromString(PythonClass cl, String str, String byteorder, Object[] args, boolean signed) {
1990-
return compute(cl, str.getBytes(), byteorder, signed);
1991-
}
1992-
1993-
@Specialization
1994-
public Object fromString(PythonClass cl, String str, String byteorder, Object[] args, PNone keywordArg) {
1995-
return fromString(cl, str, byteorder, args, false);
1996-
}
1997-
19981984
// from PBytes
19991985
@Specialization
20001986
public Object fromPBytes(PythonClass cl, PBytes bytes, String byteorder, Object[] args, boolean signed) {

graalpython/lib-graalpython/_imp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def extension_suffixes():
4848

4949
@__builtin__
5050
def get_magic():
51-
return '\x0c\xaf\xaf\xe1'
51+
return b'\x0c\xaf\xaf\xe1'
5252

5353

5454
@__builtin__

0 commit comments

Comments
 (0)