Skip to content

cannot print at all due to unicode job ownerId #137

@4gra

Description

@4gra

Symptoms: nothing prints. Vague ERROR: <jobname> output each time a job is accepted; running with -v provides no more detail on the error. Suppressing exception handling in the appropriate block revealed the following exception, referring to the options dict to the cups_connection (at cloudprint.py:421):

TypeError: Keys and values must be strings

The simplest way to fix this is simply to reverse the lines setting up the options dict, ensuring everything is a str:

cloudprint/cloudprint.py:411-412:

        options['job-originating-user-name'] = job['ownerId']
        options = dict((str(k), str(v)) for k, v in list(options.items()))

...but it occurred to me that it might be wiser to escape the userID to avoid exceptions where the userID can't be represented in ASCII:

        options = dict((str(k), str(v)) for k, v in list(options.items()))
        options['job-originating-user-name'] = job['ownerId'].encode('unicode_escape')

the latter might not result in pretty output but it'll at least preserve the connecting user ID.

I wasn't sure how you'd like to approach the solution so thought an issue was better than a PR -- but happy to prepare one if it's easier.

To be clear, my username doesn't contain anything that's not in ASCII, so assume one of my libraries is returning unicode "unexpectedly" (I haven't investigated which, but since either change will work with string job IDs I don't see that it matters).

Environment: Debian 8, Python 2.7.9, dependencies supplied by a questionable mix of Debian repositories and pypi (versions available on request if you really care!)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions