0

I am programing VIX API from python 2.5, but now I want to port the code to python 3.2

This function opens the virtual machine:

self.jobHandle = self.VixLib.vix.VixVM_Open(self.hostHandle,
                                            "C:\\MyVirtualMachine.vmx", None, None)

Previusly this function is imported from Vix.dll with this code:

vix.VixVM_Open.restype = VixHandle
vix.VixVM_Open.argtypes = [VixHandle,c_char_p,POINTER(VixEventProc),c_void_p]

In 2.5 this code is correct, but in 3.2 it returns ctypes.ArgumentError

What can I do?

4
  • I'm guessing this is related to the fact that all strings went unicode in 3.0, but I don't know what the solution is. Commented Sep 15, 2010 at 21:34
  • 1
    Including the whole stack trace might be useful. Commented Sep 15, 2010 at 21:37
  • what is whole stack trace???sorry but I´m begginer in python Commented Sep 15, 2010 at 21:46
  • It's everything the interpreter dumps out to you when it hits an exception (everything surrounding the "ArgumentError") Commented Sep 15, 2010 at 21:51

1 Answer 1

5

Your second argument has to be encoded to a format that the VIX API will understand, since Python 3.x now creates all strings as Unicode. The simplest approach would be to modify your second argument to read:

"C:\\MyVirtualMachine.vmx".encode('ascii','ignore')

which should give you a variable of type bytes, which should be more palatable to VIX.

Sign up to request clarification or add additional context in comments.

1 Comment

Making this the problem was soluted!! thank you very much!! where can I vote you???

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.