trust your head

This commit is contained in:
Vítor Santos Costa
2018-09-18 19:43:50 +01:00
parent a6e578090c
commit b6235d8ecd
5 changed files with 45 additions and 46 deletions

View File

@@ -8,7 +8,6 @@ PyObject *py_Main;
void pyErrorHandler__(int line, const char *file, const char *code) {
// this code is called if a Python error is found.
// int lvl = push_text_stack();
PyObject *type;
// PyErr_Fetch(&type, &val, NULL);
// PyErr_Print();
// Yap_ThrowError__(file,code,line,0, SYSTEM_ERROR_RUNTIME_PYTHON ,"Python
@@ -235,7 +234,7 @@ static foreign_t assign_python(term_t exp, term_t name) {
static foreign_t python_string_to(term_t f) {
if (PL_is_atom(f)) {
char *s = NULL;
if (!PL_get_chars(f, &s, CVT_ALL | CVT_EXCEPTION | REP_UTF8)) {
if (!PL_get_chars(f, &s, CVT_ATOM |CVT_STRING | CVT_EXCEPTION | REP_UTF8)) {
pyErrorAndReturn(false);
}
if (!strcmp(s,"atom")) {
@@ -571,27 +570,6 @@ static foreign_t python_export(term_t t, term_t pl) {
pyErrorAndReturn(rc);
}
static bool get_mod(const char *s0)
{
PyObject *pName;
term_t t0 = python_acquire_GIL();
#if PY_MAJOR_VERSION < 3
pName = PyString_FromString(s0);
#else
pName = PyUnicode_FromString(s0);
#endif
if (pName == NULL) {
python_release_GIL(t0);
}
PyObject *pModule = PyImport_Import(pName);
Py_XDECREF(pName);
python_release_GIL(t0);
return pModule;
}
/**
* @pred python_import(MName, Mod)
* Import a python module to the YAP environment.