Skip to content

Commit 1b854b5

Browse files
committed
Implement C API function PyUnicode_DecodeLatin1
1 parent d0bff6b commit 1b854b5

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

graalpython/com.oracle.graal.python.cext/src/unicodeobject.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -689,3 +689,14 @@ UPCALL_ID(PyUnicode_Split)
689689
PyObject* PyUnicode_Split(PyObject *s, PyObject *sep, Py_ssize_t maxsplit) {
690690
return UPCALL_CEXT_O(_jls_PyUnicode_Split, native_to_java(s), native_to_java(sep), maxsplit);
691691
}
692+
693+
// taken from CPython "Objects/unicodeobject.c"
694+
PyObject *
695+
PyUnicode_DecodeLatin1(const char *s,
696+
Py_ssize_t size,
697+
const char *errors)
698+
{
699+
/* Latin-1 is equivalent to the first 256 ordinals in Unicode. */
700+
return _PyUnicode_FromUCS1((const unsigned char*)s, size);
701+
}
702+

graalpython/lib-graalpython/modules/hpy/test/test_hpyunicode.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ def test_AsUTF8AndSize(self):
163163
assert mod.g(b'A'.decode('utf-8')) == ord('A')
164164
assert mod.g(b'A\0'.decode('utf-8')) == ord('A')
165165

166-
@pytest.mark.skip(reason="GR-40178")
167166
def test_DecodeLatin1(self):
168167
mod = self.make_module("""
169168
HPyDef_METH(f, "f", f_impl, HPyFunc_O)

0 commit comments

Comments
 (0)