1. cherrypy
  2. CherryPy
Issue #1132 resolved

cherrypy._cpcompat.ntob, fails silently on u'str'

Derek Litz
created an issue

from cherrypy._cpcompat import ntob

test_non_native_str = u'unicode string'


Out[75]: u'unicode string'

sys.version_info Out[76]: sys.version_info(major=2, minor=7, micro=2, releaselevel='final', serial=0)

Related is the usage of ntob in the SessionAuth class.


See also:


Comments (9)

  1. Jason R. Coombs

    So fumanchu said, "[ntob] should probably fail loudly if it receives a non-native string arg." That's easy to fix, but will probably trigger a new problem - where the failure will occur when username is unicode. I plan to put together a couple of tests to capture both aspects of the issue.

  2. Robert Brewer
    • changed status to open

    Thanks, Jason, for working on this. Unfortunately, I think we'd still like to support Python 3.0-3.2, which don't have support for the "u" prefix for string literals. So I think the changeset should be reworked. If a native string should always be encoded, then ntob is the right choice. If we want the login_screen method to accept either bytestrings or unicodestrings, then we'll have to do the hard work inside the function of detecting unicode args and encoding them.

  3. Log in to comment