Skip to content

Commit 5f5ee11

Browse files
committed
minor sync with P4D
1 parent e85e138 commit 5f5ee11

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

python4lazarus/PythonEngine.pas

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5077,7 +5077,7 @@ function TPythonEngine.EncodeString(const str: UnicodeString): AnsiString; {$IFD
50775077
{$IFDEF FPC}
50785078
function TPythonEngine.EncodeString (const str: AnsiString): AnsiString; overload;
50795079
begin
5080-
Result := str;
5080+
Result := UTF8Encode(str);
50815081
end;
50825082
{$ENDIF}
50835083

@@ -6718,7 +6718,7 @@ procedure TError.RaiseError( const msg : AnsiString );
67186718
begin
67196719
Owner.Owner.CheckEngine;
67206720
with Owner.Owner.Engine do
6721-
PyErr_SetString( Error, PAnsiChar(msg) );
6721+
PyErr_SetString(Error, PAnsiChar(EncodeString(msg)));
67226722
end;
67236723

67246724
procedure TError.RaiseErrorObj( const msg : AnsiString; obj : PPyObject );
@@ -6769,7 +6769,8 @@ procedure TError.RaiseErrorObj( const msg : AnsiString; obj : PPyObject );
67696769
end
67706770
else
67716771
raise Exception.Create('TError.RaiseErrorObj: I didn''t get an instance' );
6772-
PyErr_SetObject( Error, res );
6772+
PyErr_SetObject(Error, res);
6773+
Py_XDECREF(res);
67736774
end
67746775
else
67756776
PyErr_SetObject( Error, obj );
@@ -7223,7 +7224,7 @@ function TPyObject.SetAttr(key : PAnsiChar; value : PPyObject) : Integer;
72237224
begin
72247225
Result := -1;
72257226
PyErr_SetString (PyExc_AttributeError^,
7226-
PAnsiChar(AnsiString(Format('Unknown attribute "%s"',[key]))));
7227+
PAnsiChar(EncodeString(Format('Unknown attribute "%s"',[key]))));
72277228
end;
72287229
end;
72297230

0 commit comments

Comments
 (0)