Grasshopper

algorithmic modeling for Rhino

IronPython Python inconsistency (unicode argument without an encoding)

I I'm accesing from the py comp. this function that was written for Python 2 and it presents a bug that I can't solve with my basic knowledge of Ironpython. 

def simxWriteStringStream(clientID, signalName, signalValue, operationMode):

    sigV=signalValue

    if sys.version_info[0] == 3:

        if type(signalName) is str:

            signalName=signalName.encode('utf-8')

        if type(signalValue) is bytearray:

            sigV  = (ct.c_ubyte*len(signalValue))(*signalValue)

        if type(signalValue) is str:

            signalValue=signalValue.encode('utf-8')

            sigV  = (ct.c_ubyte*len(signalValue))(*signalValue)

    else:

        if type(signalValue) is bytearray:

            sigV = (ct.c_ubyte*len(signalValue))(*signalValue)

        if type(signalValue) is str:

            signalValue=bytearray(signalValue)#<========This is line 1052

            sigV = (ct.c_ubyte*len(signalValue))(*signalValue)

    sigV=ct.cast(sigV,ct.POINTER(ct.c_ubyte)) # IronPython needs this

    return c_WriteStringStream(clientID, signalName, sigV, len(signalValue), operationMode)

It displays the following error:

Program started

Connected to remote API server

Runtime error (TypeErrorException): unicode argument without an encoding

Traceback:

  line 1052, in simxWriteStringStream, "C:\Program Files (x86)\V-REP3\V-REP_PRO_EDU\programming\remoteApiBindings\python\python\vrep.py"

  line 70, in script

Any hint?

Views: 903

Replies to This Discussion

After a noon debuging with Mario Deuss we realize the problem was that there was a missing encoder in the bytearray() function when using Ironpython instead of Python. By adding bytearray(signalValue, 'utf-8') we got rid of the bug. 

Software version:

V-REP PRO EDU 3.2.1

Grasshopper 0.9.0076

Thanks for posting the solution to the issue as well!


Giulio
--
Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service