Jump to content

pyscripter

Members
  • Content Count

    785
  • Joined

  • Last visited

  • Days Won

    42

Posts posted by pyscripter


  1. exit() raises the SystemExit exception, which unlike other exceptions, results in process termination before control gets back to Delphi.  To prevent process termination you can do one of the following:

     

    • wrap the python code in a try: except SystemExit: as suggested by @fjames above
    • "overwrite" the exit method by for example running the following code after the python engine is initialized:
    def _exit():
        print("exit prevented")
    
    __builtins__.exit = _exit
    import sys
    sys.exit = _exit
    
    del(_exit)
    • overwrite the SystemExit exception!

  2. 1 hour ago, vmishka said:

    I did not add them to Windows 32-bit

    The design time packages are 32-bit so you need to add the paths to the 32-bit target.

     

    The group project contains runtime and designtime packages.

    You first need to compile/build the runtime packages for target 32-bits. Optionally and only if you want to build 64-bit applications with runtime package, build 64-bit runtime packages:

    - Python270.bpl

    - PythonVcl270.bpl

    - PythonFmx270.bpl

    Then install the Design time packages (these are always 32-bits)

    - dclPython270.bpl

    - dclPythonVcl270.bpl

    - dclPythonFmx270.bpl


  3. 4 hours ago, Steve Maughan said:

    I made the mistake of updating as soon as it was released. After installing (all default option) I found it had scrubbed my Win64 component path. The Win32 path is in tact but it'll be a right old pain to manually copy between the two. Also had to re-install OnGuard and Konopka components via GetIt (a modest pain).

    I was bitten by this a few times in previous upgrades.  This time I knew better...


  4. 5 minutes ago, balabuev said:

    I was not able to reproduce the issue.

    In the SvgIconImageList demo case, the application was compiled with the Windows default style and the error occurs when you change the style at runtime.   I think that may be significant because it causes the controls to be recreated.


  5. P4D supports named parameters as follows:

     

    requests.get('http://192.168.1.200/gci-bin/users', auth:=requests.HTTPDigestAuth('admin','admin')

    Please note the := notation.   


  6. There are many ways to achieve what you want:

     

    1. The ExecString has an overloaded form:

    procedure TPythonEngine.ExecString(const command : AnsiString; locals, globals : PPyObject );

    You can pass a new empty dictionary to the locals and globals argument if you do not want to "pollute" the interpreter namespace.

     

    2.  You can manually do the clean up as you suggest above.

     

    3.  A more advanced way is to use subinterpreters  (have a look at TPythonThread.Execute), but this is more error prone.

    • Like 1

  7. 3 hours ago, matrix1233 said:

    1 - Installed Python4lazarus (with working demo1)

     2 - using Demo1 with library of lazarus and changing the file PythonEngine.pas (lazarus) with the PythonEngine.pas (python4Delphi)  and i have the same error Error: could not map symbol "Py_DebugFlag" ) so the problem is on this file .

    Could you debug MapDLL in both and try to see whether they differ?  I have looked at the code and could not see any significant difference.

     


  8. 11 minutes ago, matrix1233 said:

    The strange think is if i install python4lazarus( https://github.com/Alexey-T/Python-for-Lazarus/) it's work

    But the two are almost identical nowadays and they both import Py_DebugFlag etc.   Could you please pinpoint what makes the differences (e.g. by stepping through the code)?  That would be very useful.  

     

    If you do have access to Delphi for the MacOS can you please also try with that?

×