@@ -1977,7 +1977,7 @@ function TPyDelphiStream.ReadBytes_Wrapper(const AArgs: PPyObject): PPyObject;
1977
1977
Py_XDecRef(LItem);
1978
1978
end ;
1979
1979
// The content
1980
- LItem := PyByteArray_FromObject (LBytes);
1980
+ LItem := PyBytes_FromObject (LBytes);
1981
1981
Py_XDecRef(LBytes);
1982
1982
PyList_Append(Result, LItem);
1983
1983
Py_XDecRef(LItem);
@@ -2059,9 +2059,9 @@ function TPyDelphiStream.WriteBytes_Wrapper(const AArgs: PPyObject): PPyObject;
2059
2059
Adjust(@Self);
2060
2060
Result := nil ;
2061
2061
with GetPythonEngine() do begin
2062
- if PyArg_ParseTuple(AArgs, ' Yi :Create' , @LValue, @LCount) <> 0 then
2063
- if PyByteArray_Check (LValue) then begin
2064
- LBuffer := TEncoding.Default.GetBytes(String(PyByteArray_AsString (LValue)));
2062
+ if PyArg_ParseTuple(AArgs, ' Si :Create' , @LValue, @LCount) <> 0 then
2063
+ if PyBytes_Check (LValue) then begin
2064
+ LBuffer := TEncoding.Default.GetBytes(String(PyBytesAsAnsiString (LValue)));
2065
2065
Result := PyLong_FromLong(DelphiObject.Write(LBuffer, LCount));
2066
2066
end ;
2067
2067
end ;
@@ -2300,13 +2300,13 @@ TBytesStreamClass = class of TBytesStream;
2300
2300
if APythonType.Engine.PyByteArray_Check(LBytes) then begin
2301
2301
DelphiObject := TBytesStreamClass(DelphiObjectClass).Create(
2302
2302
TEncoding.Default.GetBytes(
2303
- String(APythonType.Engine.PyByteArray_AsString (LBytes))));
2303
+ String(APythonType.Engine.PyByteArrayAsAnsiString (LBytes))));
2304
2304
end ;
2305
2305
end else if APythonType.Engine.PyArg_ParseTuple(args, ' S:Create' , @LBytes) <> 0 then begin
2306
2306
if APythonType.Engine.PyBytes_Check(LBytes) then begin
2307
2307
DelphiObject := TBytesStreamClass(DelphiObjectClass).Create(
2308
2308
TEncoding.Default.GetBytes(
2309
- String(APythonType.Engine.PyBytes_AsString (LBytes))));
2309
+ String(APythonType.Engine.PyBytesAsAnsiString (LBytes))));
2310
2310
end ;
2311
2311
end ;
2312
2312
0 commit comments