Skip to content

8-bit transparency under Python 3 #60

@seveas

Description

@seveas

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions