Skip to content

Commit 3a71bab

Browse files
committed
Fix for Python crash if Unicode surrogate pair passed from Pascal in Linux. pyscripter#85
1 parent 40f26b5 commit 3a71bab

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

PythonForDelphi/Components/Sources/Core/PythonEngine.pas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6419,7 +6419,7 @@ function TPythonEngine.PyUnicode_FromWideString( const AString : UnicodeString)
64196419
{$IFDEF LINUX}
64206420
// Note that Linux uses UCS4 strings, whereas it declares using UCS2 strings!!!
64216421
_ucs4Str := WideStringToUCS4String(AString);
6422-
Result := PyUnicode_FromWideChar( {PWideChar}(@_ucs4Str[0]), Length(AString) );
6422+
Result := PyUnicode_FromWideChar( {PWideChar}(@_ucs4Str[0]), Length(_ucs4Str)-1 {trim trailing zero});
64236423
{$ELSE}
64246424
Result := PyUnicode_FromWideChar( PWideChar(AString), Length(AString) );
64256425
{$ENDIF}

0 commit comments

Comments
 (0)