diff --git a/pymonetdb/sql/debug.py b/pymonetdb/sql/debug.py index e58cd056..598f8728 100644 --- a/pymonetdb/sql/debug.py +++ b/pymonetdb/sql/debug.py @@ -2,7 +2,6 @@ import tempfile import re import pdb -from past.builtins import execfile # type: ignore from typing import Any, TYPE_CHECKING @@ -27,7 +26,7 @@ def execute(self, query): del dd['_conn'] del dd['_columns'] del dd['_column_types'] - return pickle.dumps(dd); + return pickle.dumps(dd).hex(); };""") self.__conn.execute(""" SELECT * @@ -102,7 +101,8 @@ def debug(cursor, query, fname, sample=-1): arglist, fcode.replace("\n", "\n ")) f.write(function_definition.encode('utf-8')) f.flush() - execfile(f.name, globals(), locals()) + compiled = compile(function_definition, f.name, 'exec') + exec(compiled, globals(), locals()) cleaned_arguments['_conn'] = LoopbackObject(cursor) pdb.set_trace() @@ -135,7 +135,7 @@ def exportparameters(cursor, ftype, fname, query, quantity_parameters, sample): args, _, _, values = inspect.getargvalues(frame); dd = {x: values[x] for x in args}; del dd['_conn'] - return pickle.dumps(dd); + return pickle.dumps(dd).hex(); };""" % return_type else: export_function = """ @@ -162,7 +162,7 @@ def exportparameters(cursor, ftype, fname, query, quantity_parameters, sample): dd[argname] = aux print(dd[argname]) print(x) - return pickle.dumps(dd); + return pickle.dumps(dd).hex(); }; """ % (return_type, str(sample)) @@ -179,7 +179,8 @@ def exportparameters(cursor, ftype, fname, query, quantity_parameters, sample): if len(input_data) <= 0: raise Exception("Could not load input data!") - arguments = pickle.loads(input_data[0][0]) + bin_data = bytes.fromhex(input_data[0][0]) + arguments = pickle.loads(bin_data) if len(arguments) != quantity_parameters + 2: raise Exception("Incorrect amount of input arguments found!") diff --git a/tests/test_udf.py b/tests/test_udf.py index f8771002..63c75eeb 100644 --- a/tests/test_udf.py +++ b/tests/test_udf.py @@ -28,7 +28,6 @@ def tearDownClass(cls) -> None: if cls.conn: cls.conn.close() - @skip("Disabled, see issue #49") def test_debug_udf(self): self.cursor.execute(""" CREATE FUNCTION test_python_udf(i INTEGER)