Skip to content

Commit c982ed9

Browse files
committed
Add Py_IsInitialized
1 parent 9a5220f commit c982ed9

File tree

4 files changed

+14
-24
lines changed

4 files changed

+14
-24
lines changed

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

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2019, 2023, 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
@@ -40,18 +40,15 @@
4040
*/
4141
#include "capi.h"
4242

43+
int Py_IsInitialized(void) {
44+
return 1;
45+
}
46+
47+
#ifndef COMPILING_NATIVE_CAPI
4348
void _Py_NO_RETURN _Py_FatalErrorFunc(const char *func, const char *msg) {
4449
GraalPyTruffle_FatalErrorFunc(func != NULL? truffleString(func): NULL, truffleString(msg), -1);
4550
/* If the above upcall returns, then we just fall through to the 'abort' call. */
4651
abort();
4752
}
53+
#endif // COMPILING_NATIVE_CAPI
4854

49-
PyOS_sighandler_t PyOS_setsig(int sig, PyOS_sighandler_t handler) {
50-
PyErr_SetString(PyExc_SystemError, "'PyOS_setsig' not implemented");
51-
return NULL;
52-
}
53-
54-
int PyOS_InterruptOccurred(void) {
55-
PyErr_SetString(PyExc_SystemError, "'PyOS_InterruptOccurred' not implemented");
56-
return -1;
57-
}

graalpython/com.oracle.graal.python.jni/src/capi_forwards.h

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3354,10 +3354,8 @@ PyAPI_FUNC(PyObject*) PyOS_FSPath(PyObject* a) {
33543354
PyObject* result = (PyObject*) __target__PyOS_FSPath(a);
33553355
return result;
33563356
}
3357-
int (*__target__PyOS_InterruptOccurred)() = NULL;
33583357
PyAPI_FUNC(int) PyOS_InterruptOccurred() {
3359-
int result = (int) __target__PyOS_InterruptOccurred();
3360-
return result;
3358+
unimplemented("PyOS_InterruptOccurred"); exit(-1);
33613359
}
33623360
PyAPI_FUNC(char*) PyOS_Readline(FILE* a, FILE* b, const char* c) {
33633361
unimplemented("PyOS_Readline"); exit(-1);
@@ -3376,10 +3374,8 @@ PyAPI_FUNC(int) PyOS_mystricmp(const char* a, const char* b) {
33763374
PyAPI_FUNC(int) PyOS_mystrnicmp(const char* a, const char* b, Py_ssize_t c) {
33773375
unimplemented("PyOS_mystrnicmp"); exit(-1);
33783376
}
3379-
PyOS_sighandler_t (*__target__PyOS_setsig)(int, PyOS_sighandler_t) = NULL;
33803377
PyAPI_FUNC(PyOS_sighandler_t) PyOS_setsig(int a, PyOS_sighandler_t b) {
3381-
PyOS_sighandler_t result = (PyOS_sighandler_t) __target__PyOS_setsig(a, b);
3382-
return result;
3378+
unimplemented("PyOS_setsig"); exit(-1);
33833379
}
33843380
double (*__target__PyOS_string_to_double)(const char*, char**, PyObject*) = NULL;
33853381
PyAPI_FUNC(double) PyOS_string_to_double(const char* a, char** b, PyObject* c) {
@@ -4957,9 +4953,6 @@ PyAPI_FUNC(int) Py_IsFalse(PyObject* a) {
49574953
int result = (int) __target__Py_IsFalse(a);
49584954
return result;
49594955
}
4960-
PyAPI_FUNC(int) Py_IsInitialized() {
4961-
unimplemented("Py_IsInitialized"); exit(-1);
4962-
}
49634956
int (*__target__Py_IsNone)(PyObject*) = NULL;
49644957
PyAPI_FUNC(int) Py_IsNone(PyObject* a) {
49654958
int result = (int) __target__Py_IsNone(a);
@@ -6879,9 +6872,7 @@ void initializeCAPIForwards(void* (*getAPI)(const char*)) {
68796872
__target__PyNumber_TrueDivide = getAPI("PyNumber_TrueDivide");
68806873
__target__PyNumber_Xor = getAPI("PyNumber_Xor");
68816874
__target__PyOS_FSPath = getAPI("PyOS_FSPath");
6882-
__target__PyOS_InterruptOccurred = getAPI("PyOS_InterruptOccurred");
68836875
__target__PyOS_double_to_string = getAPI("PyOS_double_to_string");
6884-
__target__PyOS_setsig = getAPI("PyOS_setsig");
68856876
__target__PyOS_string_to_double = getAPI("PyOS_string_to_double");
68866877
__target__PyOS_strtol = getAPI("PyOS_strtol");
68876878
__target__PyOS_strtoul = getAPI("PyOS_strtoul");

graalpython/com.oracle.graal.python.jni/src/capi_native.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,11 +557,13 @@ char _PyByteArray_empty_string[] = "";
557557
* The following source files contain code that can be compiled directly and does not need to be called via stubs in Sulong:
558558
*/
559559

560+
#define COMPILING_NATIVE_CAPI
560561
#include "_warnings.c"
561562
#include "boolobject.c"
562563
#include "complexobject.c"
563564
#include "dictobject.c"
564565
#include "modsupport_shared.c"
566+
#include "pylifecycle.c"
565567

566568
/*
567569
* This mirrors the definition in capi.c that we us on Sulong, and needs to be

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ public final class CApiFunction {
287287
@CApiBuiltin(name = "PyModule_AddStringConstant", ret = Int, args = {PyObject, ConstCharPtrAsTruffleString, ConstCharPtrAsTruffleString}, call = CImpl)
288288
@CApiBuiltin(name = "PyModule_AddType", ret = Int, args = {PyObject, PyTypeObject}, call = CImpl)
289289
@CApiBuiltin(name = "PyObject_GenericGetDict", ret = PyObject, args = {PyObject, Pointer}, call = CImpl)
290+
@CApiBuiltin(name = "Py_IsInitialized", ret = Int, args = {}, call = CImpl)
290291

291292
/*
292293
* Functions that are implemented in C code:
@@ -581,8 +582,6 @@ public final class CApiFunction {
581582
@CApiBuiltin(name = "PyObject_SetAttrString", ret = Int, args = {PyObject, ConstCharPtrAsTruffleString, PyObject}, call = PolyglotImpl)
582583
@CApiBuiltin(name = "PyObject_VectorcallDict", ret = PyObject, args = {PyObject, PyObjectConstPtr, SIZE_T, PyObject}, call = PolyglotImpl)
583584
@CApiBuiltin(name = "PyOS_double_to_string", ret = CHAR_PTR, args = {Double, CHAR, Int, Int, INT_LIST}, call = PolyglotImpl)
584-
@CApiBuiltin(name = "PyOS_InterruptOccurred", ret = Int, args = {}, call = PolyglotImpl)
585-
@CApiBuiltin(name = "PyOS_setsig", ret = PY_OS_SIGHANDLER, args = {Int, PY_OS_SIGHANDLER}, call = PolyglotImpl)
586585
@CApiBuiltin(name = "PyOS_snprintf", ret = Int, args = {CHAR_PTR, SIZE_T, ConstCharPtrAsTruffleString, VARARGS}, forwardsTo = "PyOS_vsnprintf", call = PolyglotImpl)
587586
@CApiBuiltin(name = "PyOS_string_to_double", ret = Double, args = {ConstCharPtrAsTruffleString, CHAR_PTR_LIST, PyObject}, call = PolyglotImpl)
588587
@CApiBuiltin(name = "PyOS_strtol", ret = Long, args = {ConstCharPtrAsTruffleString, CHAR_PTR_LIST, Int}, call = PolyglotImpl)
@@ -991,7 +990,6 @@ public final class CApiFunction {
991990
@CApiBuiltin(name = "Py_Initialize", ret = Void, args = {}, call = NotImplemented)
992991
@CApiBuiltin(name = "Py_InitializeEx", ret = Void, args = {Int}, call = NotImplemented)
993992
@CApiBuiltin(name = "Py_InitializeFromConfig", ret = PYSTATUS, args = {CONST_PYCONFIG_PTR}, call = NotImplemented)
994-
@CApiBuiltin(name = "Py_IsInitialized", ret = Int, args = {}, call = NotImplemented)
995993
@CApiBuiltin(name = "Py_Main", ret = Int, args = {Int, WCHAR_T_PTR_LIST}, call = NotImplemented)
996994
@CApiBuiltin(name = "Py_MakePendingCalls", ret = Int, args = {}, call = NotImplemented)
997995
@CApiBuiltin(name = "Py_NewInterpreter", ret = PyThreadState, args = {}, call = NotImplemented)
@@ -1208,9 +1206,11 @@ public final class CApiFunction {
12081206
@CApiBuiltin(name = "PyOS_AfterFork_Parent", ret = Void, args = {}, call = NotImplemented)
12091207
@CApiBuiltin(name = "PyOS_AfterFork", ret = Void, args = {}, call = NotImplemented)
12101208
@CApiBuiltin(name = "PyOS_BeforeFork", ret = Void, args = {}, call = NotImplemented)
1209+
@CApiBuiltin(name = "PyOS_InterruptOccurred", ret = Int, args = {}, call = NotImplemented)
12111210
@CApiBuiltin(name = "PyOS_getsig", ret = PY_OS_SIGHANDLER, args = {Int}, call = NotImplemented)
12121211
@CApiBuiltin(name = "PyOS_mystricmp", ret = Int, args = {ConstCharPtrAsTruffleString, ConstCharPtrAsTruffleString}, call = NotImplemented)
12131212
@CApiBuiltin(name = "PyOS_mystrnicmp", ret = Int, args = {ConstCharPtrAsTruffleString, ConstCharPtrAsTruffleString, Py_ssize_t}, call = NotImplemented)
1213+
@CApiBuiltin(name = "PyOS_setsig", ret = PY_OS_SIGHANDLER, args = {Int, PY_OS_SIGHANDLER}, call = NotImplemented)
12141214
@CApiBuiltin(name = "PyOS_Readline", ret = CHAR_PTR, args = {FILE_PTR, FILE_PTR, ConstCharPtrAsTruffleString}, call = NotImplemented)
12151215
@CApiBuiltin(name = "PyPickleBuffer_FromObject", ret = PyObject, args = {PyObject}, call = NotImplemented)
12161216
@CApiBuiltin(name = "PyPickleBuffer_GetBuffer", ret = CONST_PY_BUFFER, args = {PyObject}, call = NotImplemented)

0 commit comments

Comments
 (0)