diff --git a/ChangeLog.md b/ChangeLog.md index 73bf8d2..681d30e 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,4 +1,4 @@ -0.3.0.0 [XXXX.XX.XX] +0.3.0.0 [2026.10.15] -------------------- * Support for asynchronous execution added in module `Python.Inline.Async`. It uses API modelled after `async` package. Such computations could be @@ -17,8 +17,16 @@ flag is set. Default behavior is unchanged. * Haskell exception raised in haskell callback will be rethrown if not caught by python instead of being converted to `PyError`. -* Memory leak in exception handling is fixed. Python exception object were never - freed when exception propagated to haskell side. +* `evalPyFunction` is added to company of `eval` and `exec`. It uses new + `PyQuoteFun` data type as parameter. +* `pySource` quasiquoter added. It loads python code from file. +* `createModule` added which gives standard way of defining python code. +* Bug fixes: + - Memory leak in exception handling is fixed. Python exception object were never + freed when exception propagated to haskell side. + - `bindVar` and `codeFromString`, `codeFromText` violated memory safety but + happened to work correctly when strings were created by TH. Consider upgrade + if using them. 0.2.1.0 [2026.01.13] ---------------- diff --git a/cbits/python.c b/cbits/python.c index 00502b4..b87b2c2 100644 --- a/cbits/python.c +++ b/cbits/python.c @@ -252,8 +252,8 @@ void inline_py_clear_error(void) { locals = PyDict_New(); code = Py_CompileString("None", "", Py_eval_input); } - PyObject* r = PyEval_EvalCode(code, globals, locals); // None is immortal. No need to decrement counter + PyEval_EvalCode(code, globals, locals); PyErr_Clear(); } diff --git a/examples/matplotlib-gui/matplotlib-gui.cabal b/examples/matplotlib-gui/matplotlib-gui.cabal index 49cb705..12f9070 100644 --- a/examples/matplotlib-gui/matplotlib-gui.cabal +++ b/examples/matplotlib-gui/matplotlib-gui.cabal @@ -50,7 +50,7 @@ Library Py.Extra executable mpl-gui-test - buildable: false + buildable: False -- Default-Language: GHC2021 main-is: test.hs diff --git a/examples/matplotlib-gui/src/Py/Matplotlib/GUI.hs b/examples/matplotlib-gui/src/Py/Matplotlib/GUI.hs index 3ed21f1..1773732 100644 --- a/examples/matplotlib-gui/src/Py/Matplotlib/GUI.hs +++ b/examples/matplotlib-gui/src/Py/Matplotlib/GUI.hs @@ -25,7 +25,6 @@ import Control.Monad.Catch import Control.Monad.IO.Class import Data.Typeable import Data.Function -import Language.Haskell.TH.Syntax qualified as TH import Python.Inline import Python.Inline.QQ diff --git a/inline-python.cabal b/inline-python.cabal index 5256541..a5cfb8d 100644 --- a/inline-python.cabal +++ b/inline-python.cabal @@ -2,7 +2,7 @@ Cabal-Version: 3.0 Build-Type: Custom Name: inline-python -Version: 0.2.1.0 +Version: 0.3.0.0 Synopsis: Python interpreter embedded into haskell. Description: This package embeds python interpreter into haskell program and diff --git a/src/Python/Inline/QQ.hs b/src/Python/Inline/QQ.hs index 0b6d443..39af688 100644 --- a/src/Python/Inline/QQ.hs +++ b/src/Python/Inline/QQ.hs @@ -156,7 +156,8 @@ pyfun = QuasiQuoter pySource :: FilePath -> TH.Q TH.Exp pySource path = do TH.addDependentFile path - [| PyQuote { code = $(TH.lift =<< TH.runIO (codeFromString <$> readFile path)) - , binder = mempty - } |] + [| PyQuote + ($(TH.lift =<< TH.runIO (codeFromString <$> readFile path))) + mempty + |]