Pull request #57 adds python 3 compatibility, but always tries to decode job bodies. Given that arbitrary byte strings may be put in the body, this is suboptimal.
For other protocol messages, only ascii content is accepted, so encoding/decoding automatically is fine.
I propose the following:
- Add an 'encoding' attribute to
Connection.__init__, defaulting to sys.getdefaultencoding
For put:
- When you put a bytes objects it's put as-is
- Otherwise it's encoded with the encoding above
And for reseve/peek etc. (_read_body):
- When a body is read:
- If encoding is
None, return a bytes object
- Otherwise decode with the specified encoding and return a string
If this design is acceptable, I'll rebase and amend the pull request to follow this design.
Pull request #57 adds python 3 compatibility, but always tries to decode job bodies. Given that arbitrary byte strings may be put in the body, this is suboptimal.
For other protocol messages, only ascii content is accepted, so encoding/decoding automatically is fine.
I propose the following:
Connection.__init__, defaulting tosys.getdefaultencodingFor put:
And for reseve/peek etc. (_read_body):
None, return a bytes objectIf this design is acceptable, I'll rebase and amend the pull request to follow this design.