Skip to content

Commit a7f2567

Browse files
committed
Streams byte manipulation enhancements
1 parent 07001b7 commit a7f2567

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Source/WrapDelphiClasses.pas

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1977,7 +1977,7 @@ function TPyDelphiStream.ReadBytes_Wrapper(const AArgs: PPyObject): PPyObject;
19771977
Py_XDecRef(LItem);
19781978
end;
19791979
//The content
1980-
LItem := PyByteArray_FromObject(LBytes);
1980+
LItem := PyBytes_FromObject(LBytes);
19811981
Py_XDecRef(LBytes);
19821982
PyList_Append(Result, LItem);
19831983
Py_XDecRef(LItem);
@@ -2059,9 +2059,9 @@ function TPyDelphiStream.WriteBytes_Wrapper(const AArgs: PPyObject): PPyObject;
20592059
Adjust(@Self);
20602060
Result := nil;
20612061
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)));
20652065
Result := PyLong_FromLong(DelphiObject.Write(LBuffer, LCount));
20662066
end;
20672067
end;
@@ -2300,13 +2300,13 @@ TBytesStreamClass = class of TBytesStream;
23002300
if APythonType.Engine.PyByteArray_Check(LBytes) then begin
23012301
DelphiObject := TBytesStreamClass(DelphiObjectClass).Create(
23022302
TEncoding.Default.GetBytes(
2303-
String(APythonType.Engine.PyByteArray_AsString(LBytes))));
2303+
String(APythonType.Engine.PyByteArrayAsAnsiString(LBytes))));
23042304
end;
23052305
end else if APythonType.Engine.PyArg_ParseTuple(args, 'S:Create', @LBytes) <> 0 then begin
23062306
if APythonType.Engine.PyBytes_Check(LBytes) then begin
23072307
DelphiObject := TBytesStreamClass(DelphiObjectClass).Create(
23082308
TEncoding.Default.GetBytes(
2309-
String(APythonType.Engine.PyBytes_AsString(LBytes))));
2309+
String(APythonType.Engine.PyBytesAsAnsiString(LBytes))));
23102310
end;
23112311
end;
23122312

0 commit comments

Comments
 (0)