summaryrefslogtreecommitdiff
path: root/cffi
diff options
context:
space:
mode:
authorArmin Rigo <arigo@tunes.org>2021-12-28 14:33:19 +0100
committerArmin Rigo <arigo@tunes.org>2021-12-28 14:33:19 +0100
commit3a5b3cab927dbf83012e9e6173c81375e36fda41 (patch)
treee2ebfd98eb91046b82d70f620a4a1c355d6d3022 /cffi
parenta333c4996bb4436d34a0dd04d46632402c66a866 (diff)
downloadcffi-3a5b3cab927dbf83012e9e6173c81375e36fda41.tar.gz
Test and fix for the case where ffi.embedding_api() is called but
does not list any `extern "Python"` function
Diffstat (limited to 'cffi')
-rw-r--r--cffi/_embedding.h3
-rw-r--r--cffi/recompiler.py5
2 files changed, 4 insertions, 4 deletions
diff --git a/cffi/_embedding.h b/cffi/_embedding.h
index e863d85..4a42cbb 100644
--- a/cffi/_embedding.h
+++ b/cffi/_embedding.h
@@ -22,7 +22,8 @@ extern "C" {
* _cffi_call_python_org, which on CPython is actually part of the
_cffi_exports[] array, is the function pointer copied from
- _cffi_backend.
+ _cffi_backend. If _cffi_start_python() fails, then this is set
+ to NULL; otherwise, it should never be NULL.
After initialization is complete, both are equal. However, the
first one remains equal to &_cffi_start_and_call_python until the
diff --git a/cffi/recompiler.py b/cffi/recompiler.py
index 86b37d7..16a7078 100644
--- a/cffi/recompiler.py
+++ b/cffi/recompiler.py
@@ -406,9 +406,8 @@ class Recompiler:
else:
prnt(' NULL, /* no includes */')
prnt(' %d, /* num_types */' % (len(self.cffi_types),))
- flags = 0
- if self._num_externpy:
- flags |= 1 # set to mean that we use extern "Python"
+ # set 'flags' to 1 in embedding mode, 0 otherwise
+ flags = int(self.ffi._embedding is not None)
prnt(' %d, /* flags */' % flags)
prnt('};')
prnt()