Skip to content

Commit 27b7ae8

Browse files
committed
Avoid access violation in TPythonModule.GetVarAsVariant (see https://en.delphipraxis.net/topic/7085-returning-lists-from-python-to-delphi/)
1 parent 4464ab6 commit 27b7ae8

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

Source/PythonEngine.pas

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7311,11 +7311,12 @@ function TPythonModule.GetVarAsVariant( const varName : AnsiString ) : Variant;
73117311
with Engine do
73127312
begin
73137313
obj := GetVar( varName );
7314-
try
7315-
Result := PyObjectAsVariant( obj );
7316-
finally
7317-
Py_XDecRef(obj);
7318-
end;
7314+
if Assigned(obj) then
7315+
try
7316+
Result := PyObjectAsVariant( obj );
7317+
finally
7318+
Py_XDecRef(obj);
7319+
end;
73197320
end;
73207321
end;
73217322

0 commit comments

Comments
 (0)