Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 3 server? #37

Open
mnar53 opened this issue Aug 13, 2018 · 3 comments
Open

Python 3 server? #37

mnar53 opened this issue Aug 13, 2018 · 3 comments

Comments

@mnar53
Copy link

mnar53 commented Aug 13, 2018

xlloop.zip

I have a Python 2 server working well, but I'd like to move to Python 3 now that 3.7 seems very performant. Just went through an automatic conversion; the converted file starts the server correctly, but starting Excel and loading xlloop.xll does not load in Excel the defined Python functions. I guess there is some difference between SocketServer (2.7) and socketserver (3.7), but I'm not able to track them.

@JS2018SJ
Copy link

JS2018SJ commented Oct 6, 2019

My experience:
In xlloop.py:

  1. SocketServer => socketserver
  2. XLCodec.decode():
    type == XL_TYPE_STR: ... return bytes.decode(socket.recv(len), 'utf8')
    XLCodec.decodeInt():
    ord(l[0]) << 24 | ord(l[1]) << 16 | ord(l[2]) << 8 | ord(l[3]) => int.from_bytes(l, 'big')
  3. XLCodec.encode():
    if isinstance(value, str): ... socket.send(value.encode())
  4. XlloopServer.start(): self.server = socketserver.ThreadingTCPServer(('localhost', self.port), XLLoopHandler)

then it seems working (Sorry I have customized code in the file and don't have time to cut a version).

@JS2018SJ
Copy link

JS2018SJ commented Oct 9, 2019

the other fix include change isinstance(value, types.IntType) to isinstance(value, int) etc.

@mnar53
Copy link
Author

mnar53 commented Oct 9, 2019

I've tried your fixes on a "clean" (basic) xlloop.py, and they work. I think did not change/add anything else, so maybe the resulting file may be of interest compared to the original Python 2 version. Thx.

xlloop3.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants