Python Crashes ATEasy

Christoph B.
Muenster, NRW

Sep 12, 2024
5 Posts

0  |  0  

Re: Python Crashes ATEasy

Even the simplest Python scripts cause ATEasy to crash. I don't even get an error message. What am I doing wrong?


pytest.py
```python
class TestClass():
    def __init__(self,addition=0):
        self.dings = 123+addition

    def testmethod(self):
        return 'test'
```


procedure
```ateasy
hPyModule=PYTHON Module Import("pytest")
if hPyModule<>0
    TestStatus=PASS
else
    TestStatus=FAIL
    exittest
endif



hPyClass=PYTHON Get Object FromAttribute(hPyModule, "TestClass")
hPyArgs=PYTHON Set Args Tuple({5})
append hPyClass

! Reference and retrieve PythonClass instance class_variable
hPyClassInstance=PYTHON Call Object(hPyClass, hPyArgs)
hPyReturn=PYTHON Get Object FromAttribute(hPyClassInstance, "dings")
TestResult=PYTHON Get Long(hPyReturn)
```

John
Irvine, CA

Sep 12, 2024
12 Posts

0  |  0  

Re: Python Crashes ATEasy

Hello,

I am able to run your example in ATEasy 23 with Python version 3.8

Which version of python are you using?
There might be a problem with the newer version of Python. Python 3.8 is stable in ATEasy

How are the hPyModule, hPyClass, etc.... defined in ATEasy Variables?
(e.g hPyModule:AHandle? or hPyModule:hPyObject?)

If the python objects are defined as AHandle, causes a memory access violation error.
Make sure the variables are defined as hPyObjects in ATEasy.


John

Christoph B.
Muenster, NRW

Sep 12, 2024
5 Posts

0  |  0  

Re: Python Crashes ATEasy

hi John,

i am also using Python 3.8. all the hPy... variables are AHandle.

i have created a completely new workspace to exclude other sources and now i get a memory access violation with the sent example

here my full workspace


File Attachment:
pymintest.zip

Solution Available
John
Irvine, CA

Sep 13, 2024
12 Posts

1  |  0  

Re: Python Crashes ATEasy

Change the hPy.. type to hPyObjects.

John

Solution Available
John
Irvine, CA

Sep 13, 2024
12 Posts

1  |  0  

Re: Python Crashes ATEasy

see attached


File Attachment:
hPyOjbects.JPG

Solution Available
John
Irvine, CA

Sep 13, 2024
12 Posts

1  |  0  

Re: Python Crashes ATEasy

John wrote:
see attached


sorry there is a typo on the type: it should be hPyObject

i attached an updated version of your project


File Attachment:
pymintest (2).zip

Solution Available
John
Irvine, CA

Sep 13, 2024
12 Posts

1  |  0  

Re: Python Crashes ATEasy

John wrote:
see attached


sorry there is a typo on the type: it should be hPyObject

i attached an updated version of your project


File Attachment:
pymintest (2).zip



Please Note
You need to have a M@GIC account to participate in the Forums.
Not yet registered on our website? Click here to register today!

All content, information and opinions presented on the Marvin Test Solutions User Forums are those of the authors of the posts and messages and not Marvin Test Solutions'. All attachments and files are downloaded at your own risk. [Read More]