Skip to content

Commit

Permalink
Test for undefined constants
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardalee committed Jul 2, 2024
1 parent 193b629 commit ae9e5f4
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion python/lib/pythontarget.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,24 @@ PyObject* py_request_stop(PyObject* self, PyObject* args) {
return Py_None;
}

PyObject* py_source_directory(PyObject* self, PyObject* args) { return PyUnicode_DecodeFSDefault(LF_SOURCE_DIRECTORY); }
PyObject* py_source_directory(PyObject* self, PyObject* args) {
#ifndef LF_SOURCE_DIRECTORY
// This should not occur.
PyErr_SetString(PyExc_RuntimeError, "LF_SOURCE_DIRECTORY constant is not defined.");
return NULL;
#else
return PyUnicode_DecodeFSDefault(LF_SOURCE_DIRECTORY);
#endif
}

PyObject* py_package_directory(PyObject* self, PyObject* args) {
#ifndef LF_PACKAGE_DIRECTORY
// This should not occur.
PyErr_SetString(PyExc_RuntimeError, "LF_PACKAGE_DIRECTORY constant is not defined.");
return NULL;
#else
return PyUnicode_DecodeFSDefault(LF_PACKAGE_DIRECTORY);
#endif
}

/**
Expand Down

0 comments on commit ae9e5f4

Please sign in to comment.