Skip to content

Commit 43701a0

Browse files
committed
EncodeWindowsFilePath added
1 parent a204252 commit 43701a0

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

PythonForDelphi/Components/Sources/Core/PythonEngine.pas

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2254,6 +2254,7 @@ TPythonEngine = class(TPythonInterface)
22542254
function Run_CommandAsObject(const command : AnsiString; mode : Integer) : PPyObject;
22552255
function Run_CommandAsObjectWithDict(const command : AnsiString; mode : Integer; locals, globals : PPyObject) : PPyObject;
22562256
function EncodeString (const str: string): AnsiString;
2257+
function EncodeWindowsFilePath (const str: string): AnsiString;
22572258
procedure ExecString(const command : AnsiString); overload;
22582259
procedure ExecStrings( strings : TStrings ); overload;
22592260
function EvalString(const command : AnsiString) : PPyObject; overload;
@@ -4901,11 +4902,7 @@ procedure TPythonEngine.SetInitScript(Value: TStrings);
49014902
function TPythonEngine.GetInterpreterState: PPyInterpreterState;
49024903
var
49034904
res: PPyThreadState;
4904-
MajorVersion : integer;
4905-
MinorVersion : integer;
49064905
begin
4907-
MajorVersion := StrToInt(RegVersion[1]);
4908-
MinorVersion := StrToInt(RegVersion[3]);
49094906
if Assigned(PyThreadState_Get) then begin
49104907
res:= PyThreadState_Get();
49114908
if (MajorVersion > 3) or ((MajorVersion = 3) and (MinorVersion >= 4)) then
@@ -5694,6 +5691,15 @@ function TPythonEngine.EncodeString(const str: string): AnsiString;
56945691
Result := AnsiString(str);
56955692
end;
56965693

5694+
function TPythonEngine.EncodeWindowsFilePath(const str: string): AnsiString;
5695+
{PEP 529}
5696+
begin
5697+
if (MajorVersion > 3) or ((MajorVersion = 3) and (MinorVersion >=6) )then
5698+
Result := UTF8Encode(str)
5699+
else
5700+
Result := AnsiString(str);
5701+
end;
5702+
56975703
function TPythonEngine.TypeByName( const aTypeName : AnsiString ) : PPyTypeObject;
56985704
var
56995705
i : Integer;

0 commit comments

Comments
 (0)