summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2012-03-28 18:57:55 -0400
committerJason R. Coombs <jaraco@jaraco.com>2012-03-28 18:57:55 -0400
commitef56af7d85746127e38b3d37c2c413e72d42a401 (patch)
treeb7b48a58ae146bcb0b866b114c3a71dd9625f9bb
parent377b99bf1768faee2c699efb37ff53157933d8a4 (diff)
parent371cef3ea218ebbec8aea562133d269b2097a42e (diff)
downloadcherrypy-git-ef56af7d85746127e38b3d37c2c413e72d42a401.tar.gz
Merge with cherrypy-3.2.x
-rw-r--r--cherrypy/lib/cptools.py6
-rw-r--r--cherrypy/test/test_tools.py5
2 files changed, 6 insertions, 5 deletions
diff --git a/cherrypy/lib/cptools.py b/cherrypy/lib/cptools.py
index 199f134d..5ae40b02 100644
--- a/cherrypy/lib/cptools.py
+++ b/cherrypy/lib/cptools.py
@@ -4,7 +4,7 @@ import logging
import re
import cherrypy
-from cherrypy._cpcompat import basestring, md5, set
+from cherrypy._cpcompat import basestring, md5, set, unicodestr
from cherrypy.lib import httputil as _httputil
@@ -299,7 +299,7 @@ class SessionAuth(object):
pass
def login_screen(self, from_page='..', username='', error_msg='', **kwargs):
- return (u"""<html><body>
+ return (unicodestr("""<html><body>
Message: %(error_msg)s
<form method="post" action="do_login">
Login: <input type="text" name="username" value="%(username)s" size="10" /><br />
@@ -307,7 +307,7 @@ Message: %(error_msg)s
<input type="hidden" name="from_page" value="%(from_page)s" /><br />
<input type="submit" />
</form>
-</body></html>""" % vars()).encode("utf-8")
+</body></html>""") % vars()).encode("utf-8")
def do_login(self, username, password, from_page='..', **kwargs):
"""Login. May raise redirect, or return True if request handled."""
diff --git a/cherrypy/test/test_tools.py b/cherrypy/test/test_tools.py
index 448e8866..21ada1f7 100644
--- a/cherrypy/test/test_tools.py
+++ b/cherrypy/test/test_tools.py
@@ -5,7 +5,7 @@ import sys
import unittest
from cherrypy._cpcompat import BytesIO, copyitems, itervalues
from cherrypy._cpcompat import IncompleteRead, ntob, ntou, py3k, xrange
-from cherrypy._cpcompat import bytestr
+from cherrypy._cpcompat import bytestr, unicodestr
import time
timeout = 0.2
import types
@@ -405,5 +405,6 @@ class SessionAuthTest(unittest.TestCase):
username and password were unicode.
"""
sa = cherrypy.lib.cptools.SessionAuth()
- res = sa.login_screen(None, username=u'nobody', password=u'anypass')
+ res = sa.login_screen(None, username=unicodestr('nobody'),
+ password=unicodestr('anypass'))
self.assertIsInstance(res, bytestr)