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

Port to python3 #7

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

rlaager
Copy link
Contributor

@rlaager rlaager commented Jan 28, 2019

I'm not sure if you're interested in a Python 3 port, but since I went to the work to figure this out for myself, I figured I might as well share it.

The split was added to fix this problem, but the maxsplit parameter is
incorrect.
Python 3 differentiates strings and bytes.

I also move the .split() and eliminated what is essentially duplicate
logging of the incoming command.  If logging both the split and unsplit
version is desired, the previous code seems backwards anyway.  Rather
than logging it split and then re-joining it, it should be logged
unsplit and then after the split.
@indeyets
Copy link

indeyets commented Aug 9, 2021

line 91 should be converted to sys.stdin.buffer.read too. otherwise, code will sporadically fail (because buffer will fetch more than 2 bytes internally and direct call on line 91 would miss part of data)

@rlaager
Copy link
Contributor Author

rlaager commented Aug 9, 2021

That seems reasonable to me. If someone is ever looking to merge this, by all means change that too.

Edit: Upon further testing, it needs to be:
sys.stdin.buffer.read(size).decode(sys.stdin.encoding)

Otherwise, it changes the returned value from a string to bytes.

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

Successfully merging this pull request may close these issues.

2 participants