Skip to content

Commit 0354b76

Browse files
committed
Renamed PyUnicode_AsWideString to PyUnicodeAsString
1 parent 9b4e1f8 commit 0354b76

File tree

10 files changed

+27
-27
lines changed

10 files changed

+27
-27
lines changed

Demos/Demo25/fmMain.pas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ procedure TMain.btnTestStringsClick(Sender: TObject);
493493
// Unicode strings
494494
b := VarPythonEval( 'u"Hello world!"' );
495495
Assert( VarIsPythonUnicode(b) );
496-
w := PythonEngine1.PyUnicode_AsWideString(ExtractPythonObjectFrom(b));
496+
w := PythonEngine1.PyUnicodeAsString(ExtractPythonObjectFrom(b));
497497
Assert( w = 'Hello world!');
498498
Assert( b = 'Hello world!');
499499
Assert( b <> a );

Demos/Demo26/Unit1.pas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ function TPyPoint_SetName( obj, value : PPyObject; context : Pointer) : integer;
116116
begin
117117
if PyUnicode_Check(value) then
118118
begin
119-
TPyPoint(PythonToDelphi(obj)).Name := PyUnicode_AsWideString(value);
119+
TPyPoint(PythonToDelphi(obj)).Name := PyUnicodeAsString(value);
120120
Result := 0;
121121
end
122122
else

Demos/Demo34/Unit1.pas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ function TPyPoint_SetName( obj, value : PPyObject; context : Pointer) : integer;
193193
begin
194194
if PyUnicode_Check(value) then
195195
begin
196-
TPyPoint(PythonToDelphi(obj)).Name := PyUnicode_AsWideString(value);
196+
TPyPoint(PythonToDelphi(obj)).Name := PyUnicodeAsString(value);
197197
Result := 0;
198198
end
199199
else

Source/PythonEngine.pas

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1805,7 +1805,7 @@ TPythonEngine = class(TPythonInterface)
18051805
{ String conversion }
18061806
function PyUnicodeFromString(const AString : UnicodeString) : PPyObject; overload;
18071807
function PyUnicodeFromString(const AString: AnsiString): PPyObject; overload;
1808-
function PyUnicode_AsWideString( obj : PPyObject ) : UnicodeString;
1808+
function PyUnicodeAsString( obj : PPyObject ) : UnicodeString;
18091809

18101810
// Public Properties
18111811
property ClientCount : Integer read GetClientCount;
@@ -4583,15 +4583,15 @@ procedure TPythonEngine.RaiseError;
45834583
tmp := PyObject_GetAttrString(err_value, 'filename');
45844584
if tmp <> nil then begin
45854585
if PyUnicode_Check(tmp) then
4586-
s_filename := PyUnicode_AsWideString(tmp)
4586+
s_filename := PyUnicodeAsString(tmp)
45874587
else if tmp = Py_None then
45884588
s_filename := '???';
45894589
Py_XDECREF(tmp);
45904590
end;
45914591
// Get the text containing the error, cut of carriage return
45924592
tmp := PyObject_GetAttrString(err_value, 'text');
45934593
if Assigned(tmp) and PyUnicode_Check(tmp) then
4594-
s_line := Trim(PyUnicode_AsWideString(tmp));
4594+
s_line := Trim(PyUnicodeAsString(tmp));
45954595
Py_XDECREF(tmp);
45964596
// Get the offset where the error should appear
45974597
tmp := PyObject_GetAttrString(err_value, 'offset' );
@@ -4606,7 +4606,7 @@ procedure TPythonEngine.RaiseError;
46064606
// Get the message of the error
46074607
tmp := PyObject_GetAttrString(err_value, 'msg' );
46084608
if Assigned(tmp) and PyUnicode_Check(tmp) then
4609-
s_value := PyUnicode_AsWideString(tmp);
4609+
s_value := PyUnicodeAsString(tmp);
46104610
Py_XDECREF(tmp);
46114611
end;
46124612
// If all is ok
@@ -4756,13 +4756,13 @@ function TPythonEngine.PyObjectAsString( obj : PPyObject ) : string;
47564756

47574757
if PyUnicode_Check(obj) then
47584758
begin
4759-
W := PyUnicode_AsWideString(obj);
4759+
W := PyUnicodeAsString(obj);
47604760
Result := string(W);
47614761
Exit;
47624762
end;
47634763
S := PyObject_Str( obj );
47644764
if Assigned(S) and PyUnicode_Check(S) then
4765-
Result := PyUnicode_AsWideString(S);
4765+
Result := PyUnicodeAsString(S);
47664766
Py_XDECREF(S);
47674767
end;
47684768

@@ -5205,7 +5205,7 @@ function TPythonEngine.PyObjectAsVariant( obj : PPyObject ) : Variant;
52055205
else if PyLong_Check(obj) then
52065206
Result := PyLong_AsLongLong(obj)
52075207
else if PyUnicode_Check(obj) then
5208-
Result := PyUnicode_AsWideString(obj)
5208+
Result := PyUnicodeAsString(obj)
52095209
else if PyBytes_Check(obj) then
52105210
Result := AnsiString(PyBytes_AsString(obj))
52115211
else if ExtractDate( Result ) then
@@ -5476,7 +5476,7 @@ procedure TPythonEngine.PyTupleToStrings( tuple: PPyObject; strings : TStrings )
54765476
strings.Add( PyObjectAsString( PyTuple_GetItem( tuple, i ) ) );
54775477
end;
54785478

5479-
function TPythonEngine.PyUnicode_AsWideString( obj : PPyObject ) : UnicodeString;
5479+
function TPythonEngine.PyUnicodeAsString( obj : PPyObject ) : UnicodeString;
54805480
var
54815481
_size : Integer;
54825482
{$IFDEF POSIX}
@@ -5507,7 +5507,7 @@ function TPythonEngine.PyUnicode_AsWideString( obj : PPyObject ) : UnicodeString
55075507
Result := '';
55085508
end
55095509
else
5510-
raise EPythonError.Create('PyUnicode_AsWideString expects a Unicode Python object');
5510+
raise EPythonError.Create('PyUnicodeAsString expects a Unicode Python object');
55115511
end;
55125512

55135513
function TPythonEngine.PyUnicodeFromString(const AString : UnicodeString) : PPyObject;
@@ -8602,7 +8602,7 @@ function pyio_write(self, args : PPyObject) : PPyObject;
86028602
if RedirectIO and (IO <> nil) and Assigned(a1) then
86038603
begin
86048604
if PyUnicode_Check(a1) then
8605-
IO.Write(PyUnicode_AsWideString(a1))
8605+
IO.Write(PyUnicodeAsString(a1))
86068606
else
86078607
IO.Write(IOString(PyObjectAsString(a1)));
86088608
end;

Source/VarPyth.pas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2346,7 +2346,7 @@ function TPythonData.GetAsVariant: Variant;
23462346
function TPythonData.GetAsWideString: UnicodeString;
23472347
begin
23482348
if Assigned(PyObject) and GetPythonEngine.PyUnicode_Check(PyObject) then
2349-
Result := GetPythonEngine.PyUnicode_AsWideString(PyObject)
2349+
Result := GetPythonEngine.PyUnicodeAsString(PyObject)
23502350
else
23512351
Result := UnicodeString(GetAsString);
23522352
end;

Source/WrapDelphi.pas

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,7 +1190,7 @@ function CheckStrAttribute(AAttribute : PPyObject; const AAttributeName : string
11901190
begin
11911191
if GetPythonEngine.PyUnicode_Check(AAttribute) then
11921192
begin
1193-
AValue := GetPythonEngine.PyUnicode_AsWideString(AAttribute);
1193+
AValue := GetPythonEngine.PyUnicodeAsString(AAttribute);
11941194
Result := True;
11951195
end
11961196
else
@@ -2004,7 +2004,7 @@ function TPyRttiObject.GetAttrO(key: PPyObject): PPyObject;
20042004
begin
20052005
Result := nil;
20062006
if (fAddr <> nil) and GetPythonEngine.PyUnicode_Check(Key) then
2007-
KeyName := GetPythonEngine.PyUnicode_AsWideString(Key)
2007+
KeyName := GetPythonEngine.PyUnicodeAsString(Key)
20082008
else
20092009
Exit;
20102010

@@ -2040,7 +2040,7 @@ function TPyRttiObject.SetAttrO(key, value: PPyObject): Integer;
20402040
begin
20412041
Result := -1;
20422042
if (fAddr <> nil) and GetPythonEngine.PyUnicode_Check(Key) then
2043-
KeyName := GetPythonEngine.PyUnicode_AsWideString(Key)
2043+
KeyName := GetPythonEngine.PyUnicodeAsString(Key)
20442044
else begin
20452045
Exit;
20462046
end;
@@ -2136,7 +2136,7 @@ function TPyDelphiObject.GetAttrO(key: PPyObject): PPyObject;
21362136
if GetPythonEngine.PyErr_Occurred = nil then Exit; // We found what we wanted
21372137

21382138
if Assigned(DelphiObject) and GetPythonEngine.PyUnicode_Check(Key) then
2139-
KeyName := GetPythonEngine.PyUnicode_AsWideString(Key)
2139+
KeyName := GetPythonEngine.PyUnicodeAsString(Key)
21402140
else
21412141
Exit;
21422142

@@ -2494,7 +2494,7 @@ function TPyDelphiObject.SetAttrO(key, value: PPyObject): Integer;
24942494
begin
24952495
Result := -1;
24962496
if Assigned(DelphiObject) and GetPythonEngine.PyUnicode_Check(Key) then
2497-
KeyName := GetPythonEngine.PyUnicode_AsWideString(Key)
2497+
KeyName := GetPythonEngine.PyUnicodeAsString(Key)
24982498
else begin
24992499
Exit;
25002500
end;

Source/WrapDelphiClasses.pas

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ function TComponentsAccess.IndexOf(AValue: PPyObject): Integer;
641641
begin
642642
if PyUnicode_Check(AValue) then
643643
begin
644-
S := PyUnicode_AsWideString(AValue);
644+
S := PyUnicodeAsString(AValue);
645645
for i := 0 to Container.ComponentCount-1 do
646646
if SameText( Container.Components[i].Name, S) then
647647
begin
@@ -887,7 +887,7 @@ function TPyDelphiComponent.GetAttrO(key: PPyObject): PPyObject;
887887
begin
888888
if GetPythonEngine.PyUnicode_Check(Key) then
889889
begin
890-
Name := GetPythonEngine.PyUnicode_AsWideString(Key);
890+
Name := GetPythonEngine.PyUnicodeAsString(Key);
891891
// try a sub component
892892
Component := DelphiObject.FindComponent(Name);
893893
if Component <> nil then
@@ -969,7 +969,7 @@ function TPyDelphiComponent.MpSubscript(obj: PPyObject): PPyObject;
969969
Result := SqItem(PyLong_AsLong(obj))
970970
else if PyUnicode_Check(obj) then
971971
begin
972-
_name := PyUnicode_AsWideString(obj);
972+
_name := PyUnicodeAsString(obj);
973973
_comp := DelphiObject.FindComponent(_name);
974974
if Assigned(_comp) then
975975
Result := Wrap(_comp)
@@ -1079,7 +1079,7 @@ function TStringsAccess.SetItem(AIndex: Integer; AValue: PPyObject): Boolean;
10791079
begin
10801080
if PyUnicode_Check(AValue) then
10811081
begin
1082-
Container[AIndex] := PyUnicode_AsWideString(AValue);
1082+
Container[AIndex] := PyUnicodeAsString(AValue);
10831083
Result := True;
10841084
end
10851085
else

Source/WrapDelphiComCtrls.pas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ function TPagesAccess.IndexOf(AValue: PPyObject): Integer;
526526
begin
527527
if PyUnicode_Check(AValue) then
528528
begin
529-
S := PyUnicode_AsWideString(AValue);
529+
S := PyUnicodeAsString(AValue);
530530
for i := 0 to Container.PageCount-1 do
531531
if SameText( Container.Pages[i].Name, S) then
532532
begin

Source/WrapDelphiControls.pas

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ function TControlsAccess.IndexOf(AValue: PPyObject): Integer;
448448
begin
449449
if PyUnicode_Check(AValue) then
450450
begin
451-
S := PyUnicode_AsWideString(AValue);
451+
S := PyUnicodeAsString(AValue);
452452
for i := 0 to Container.ControlCount-1 do
453453
if SameText( Container.Controls[i].Name, S) then
454454
begin
@@ -682,7 +682,7 @@ procedure TKeyPressEventHandler.DoEvent(Sender: TObject;
682682
Key := #0
683683
else if PyUnicode_Check(_varParam.Value) then
684684
begin
685-
_key := PyUnicode_AsWideString(_varParam.Value);
685+
_key := PyUnicodeAsString(_varParam.Value);
686686
if Length(_key) > 0 then
687687
Key := _key[1];
688688
end;

Tests/VarPythTest.pas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,7 @@ procedure TTestVarPyth.TestStrings;
788788
// Unicode strings
789789
b := VarPythonEval( 'u"Hello world!"' );
790790
Assert.IsTrue( VarIsPythonUnicode(b) );
791-
w := PythonEngine.PyUnicode_AsWideString(ExtractPythonObjectFrom(b));
791+
w := PythonEngine.PyUnicodeAsString(ExtractPythonObjectFrom(b));
792792
Assert.IsTrue( w = 'Hello world!');
793793
Assert.IsTrue( b = 'Hello world!');
794794
Assert.IsTrue( b <> a );

0 commit comments

Comments
 (0)