diff options
author | Martin Braun <martin.braun@ettus.com> | 2021-06-22 12:01:43 +0200 |
---|---|---|
committer | Aaron Rossetto <aaron.rossetto@ni.com> | 2021-06-23 07:14:12 -0500 |
commit | 0c5c2e39f9227825a4cd83a0df4efff25275e556 (patch) | |
tree | 00cf23305887dda1594f9b676e603e6275f08327 /host/lib/deps/pybind11/include/pybind11/eval.h | |
parent | a9395823ed450aefa1c2d0c894dbcf976264365e (diff) | |
download | uhd-0c5c2e39f9227825a4cd83a0df4efff25275e556.tar.gz uhd-0c5c2e39f9227825a4cd83a0df4efff25275e556.tar.bz2 uhd-0c5c2e39f9227825a4cd83a0df4efff25275e556.zip |
lib: deps: Upgrade vendor version of Pybind11 to 2.6.1
- Copied include/pybind11 directory over from source repo
- Also re-ran remove_comments.py as before
This fixes this warning on newer Python libraries:
.../internals.h: 200:9: warning: 'PyEval_InitThreads' is deprecated
[-Wdeprecated-declarations]
PyEval_InitThreads();
^
/usr/include/python3.9/ceval.h:130:1: note: 'PyEval_InitThreads' has
been explicitly marked deprecated here
Py_DEPRECATED(3.9) PyAPI_FUNC(void) PyEval_InitThreads(void);
^
/usr/include/python3.9/pyport.h:508:54: note: expanded from macro
'Py_DEPRECATED'
#define Py_DEPRECATED(VERSION_UNUSED) __attribute__((__deprecated__))
It also obviates the need for patches to Pybind11 to silence clang
warnings.
Diffstat (limited to 'host/lib/deps/pybind11/include/pybind11/eval.h')
-rw-r--r-- | host/lib/deps/pybind11/include/pybind11/eval.h | 43 |
1 files changed, 38 insertions, 5 deletions
diff --git a/host/lib/deps/pybind11/include/pybind11/eval.h b/host/lib/deps/pybind11/include/pybind11/eval.h index 15e61293d..9bbad4e9b 100644 --- a/host/lib/deps/pybind11/include/pybind11/eval.h +++ b/host/lib/deps/pybind11/include/pybind11/eval.h @@ -6,13 +6,27 @@ */ - - #pragma once #include "pybind11.h" -NAMESPACE_BEGIN(PYBIND11_NAMESPACE) +PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE) +PYBIND11_NAMESPACE_BEGIN(detail) + +inline void ensure_builtins_in_globals(object &global) { + #if PY_VERSION_HEX < 0x03080000 + + + + + if (!global.contains("__builtins__")) + global["__builtins__"] = module_::import(PYBIND11_BUILTINS_MODULE); + #else + (void) global; + #endif +} + +PYBIND11_NAMESPACE_END(detail) enum eval_mode { @@ -30,6 +44,8 @@ object eval(str expr, object global = globals(), object local = object()) { if (!local) local = global; + detail::ensure_builtins_in_globals(global); + std::string buffer = "# -*- coding: utf-8 -*-\n" + (std::string) expr; @@ -50,7 +66,7 @@ object eval(str expr, object global = globals(), object local = object()) { template <eval_mode mode = eval_expr, size_t N> object eval(const char (&s)[N], object global = globals(), object local = object()) { - auto expr = (s[0] == '\n') ? str(module::import("textwrap").attr("dedent")(s)) + auto expr = (s[0] == '\n') ? str(module_::import("textwrap").attr("dedent")(s)) : str(s); return eval<mode>(expr, global, local); } @@ -64,11 +80,27 @@ void exec(const char (&s)[N], object global = globals(), object local = object() eval<eval_statements>(s, global, local); } +#if defined(PYPY_VERSION) && PY_VERSION_HEX >= 0x03000000 +template <eval_mode mode = eval_statements> +object eval_file(str, object, object) { + pybind11_fail("eval_file not supported in PyPy3. Use eval"); +} +template <eval_mode mode = eval_statements> +object eval_file(str, object) { + pybind11_fail("eval_file not supported in PyPy3. Use eval"); +} +template <eval_mode mode = eval_statements> +object eval_file(str) { + pybind11_fail("eval_file not supported in PyPy3. Use eval"); +} +#else template <eval_mode mode = eval_statements> object eval_file(str fname, object global = globals(), object local = object()) { if (!local) local = global; + detail::ensure_builtins_in_globals(global); + int start; switch (mode) { case eval_expr: start = Py_eval_input; break; @@ -111,5 +143,6 @@ object eval_file(str fname, object global = globals(), object local = object()) throw error_already_set(); return reinterpret_steal<object>(result); } +#endif -NAMESPACE_END(PYBIND11_NAMESPACE) +PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE) |