From a275068193c87c5a27758c17d7699e963a0bdfa8 Mon Sep 17 00:00:00 2001 From: Siu Kwan Lam Date: Fri, 22 Feb 2013 17:58:38 -0600 Subject: [PATCH] Fix formatted_raw_ostream ownership error with the underlying stream. --- llvmpy/src/Support/FormattedStream.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/llvmpy/src/Support/FormattedStream.py b/llvmpy/src/Support/FormattedStream.py index 17c259b..26f906d 100644 --- a/llvmpy/src/Support/FormattedStream.py +++ b/llvmpy/src/Support/FormattedStream.py @@ -5,5 +5,11 @@ from raw_ostream import raw_ostream @llvm.Class(raw_ostream) class formatted_raw_ostream: _include_ = 'llvm/Support/FormattedStream.h' - new = Constructor(ref(raw_ostream), cast(bool, Bool)) + _new = Constructor(ref(raw_ostream), cast(bool, Bool)) + + @CustomPythonStaticMethod + def new(stream, destroy=False): + inst = formatted_raw_ostream._new(stream, destroy) + inst.__underlying_stream = stream # to prevent it being freed first + return inst