Jump to content

vanners

Members
  • Content Count

    1
  • Joined

  • Last visited

Community Reputation

0 Neutral
  1. Continuing on from the bug report I made in https://github.com/pyscripter/python4delphi/issues/270 I have attached my solution. In this solution I am attempting two ways of using a Delphi interface within Python. The project is set up so that by clicking Run the way that works is tried. Very smooth, using conversion of an interface into a PPyObject that is packaged into a PyDict object that is inserted into the python code via the locals parameter of the ExecString and EvalString calls. The second solution is activated by (within the running application): 1. Uncommenting lines 3-5 2. Commenting out lines 7-9 3. Deleting the command line text completely When running under these conditions a call is made to MakeSomething, a wrapped function that uses practically identical code to the working code referred to above. The difference is this time the object is passed back by the wrapped function call. To ensure the interfaced object is not reference counted out of existence, the temporary Interface variable has been moved into the form's fields, ensuring a reference count remains. This shouldn't be necessary, and appears to make no difference to the outcome either way. In the bug report response the first issue identified was reference counting, however Delphi reference counting is not a problem, so how does this code contravene python reference counting? Do I need to add a reference count during the creation process within the wrapped method? I am fairly certain the method was wrapped correctly, happy to be corrected if I have done something wrong. The third item in the bug report is why I am continuing the conversation here. I do question (if my code is correct) why practically identical code should have vastly different outcomes - it appeared to be a bug to me. Could the problem be that the function is not a Python object constructor? PythonIntfTest.zip
×