Skip to content

Commit 95c6a2d

Browse files
committed
Add PyCodec_StrictErrors
1 parent fbf5dff commit 95c6a2d

File tree

2 files changed

+12
-2
lines changed
  • graalpython
    • com.oracle.graal.python.cext/src
    • com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi

2 files changed

+12
-2
lines changed

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* The Universal Permissive License (UPL), Version 1.0
@@ -42,3 +42,13 @@
4242

4343

4444
const char *Py_hexdigits = "0123456789abcdef";
45+
46+
47+
PyObject *PyCodec_StrictErrors(PyObject *exc)
48+
{
49+
if (PyExceptionInstance_Check(exc))
50+
PyErr_SetObject(PyExceptionInstance_Class(exc), exc);
51+
else
52+
PyErr_SetString(PyExc_TypeError, "codec must pass exception instance");
53+
return NULL;
54+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ public final class CApiFunction {
221221
@CApiBuiltin(name = "PyCMethod_New", ret = PyObject, args = {PyMethodDef, PyObject, PyObject, PyTypeObject}, call = CImpl)
222222
@CApiBuiltin(name = "PyCode_New", ret = PyCodeObject, args = {Int, Int, Int, Int, Int, PyObject, PyObject, PyObject, PyObject, PyObject, PyObject, PyObject, PyObject, PyObject, Int, PyObject,
223223
PyObject}, call = CImpl)
224+
@CApiBuiltin(name = "PyCodec_StrictErrors", ret = PyObject, args = {PyObject}, call = CImpl)
224225
@CApiBuiltin(name = "PyComplex_AsCComplex", ret = PY_COMPLEX, args = {PyObject}, call = CImpl)
225226
@CApiBuiltin(name = "PyComplex_FromCComplex", ret = PyObject, args = {PY_COMPLEX}, call = CImpl)
226227
@CApiBuiltin(name = "PyComplex_ImagAsDouble", ret = ArgDescriptor.Double, args = {PyObject}, call = CImpl)
@@ -680,7 +681,6 @@ public final class CApiFunction {
680681
@CApiBuiltin(name = "PyCodec_ReplaceErrors", ret = PyObject, args = {PyObject}, call = NotImplemented)
681682
@CApiBuiltin(name = "PyCodec_StreamReader", ret = PyObject, args = {ConstCharPtrAsTruffleString, PyObject, ConstCharPtrAsTruffleString}, call = NotImplemented)
682683
@CApiBuiltin(name = "PyCodec_StreamWriter", ret = PyObject, args = {ConstCharPtrAsTruffleString, PyObject, ConstCharPtrAsTruffleString}, call = NotImplemented)
683-
@CApiBuiltin(name = "PyCodec_StrictErrors", ret = PyObject, args = {PyObject}, call = NotImplemented)
684684
@CApiBuiltin(name = "PyCodec_Unregister", ret = Int, args = {PyObject}, call = NotImplemented)
685685
@CApiBuiltin(name = "PyCodec_XMLCharRefReplaceErrors", ret = PyObject, args = {PyObject}, call = NotImplemented)
686686
@CApiBuiltin(name = "PyCompile_OpcodeStackEffect", ret = Int, args = {Int, Int}, call = NotImplemented)

0 commit comments

Comments
 (0)