Skip to content

Commit

Permalink
Python 3 compatibility fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
prologic committed Aug 14, 2014
1 parent 8e8b6ff commit 00de276
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 88 deletions.
4 changes: 2 additions & 2 deletions circuits/web/sessions.py
Expand Up @@ -18,13 +18,13 @@
from circuits import handler, Component


def who(request):
def who(request, encoding="utf-8"):
"""Create a SHA1 Hash of the User's IP Address and User-Agent"""

ip = request.remote.ip
agent = request.headers.get("User-Agent", "")

return sha("{0:s}{1:s}".format(ip, agent)).hexdigest()
return sha("{0:s}{1:s}".format(ip, agent).encode(encoding)).hexdigest()


def create_session(request):
Expand Down
2 changes: 1 addition & 1 deletion circuits/web/url.py
Expand Up @@ -71,7 +71,7 @@ def parse(cls, url, encoding):
parsed = urlparse(url.decode(encoding).encode('utf-8'))

try:
port = "{0:d}".format(parsed.port).encode("utf-8")
port = str(parsed.port).encode("utf-8")
except ValueError:
port = None

Expand Down

0 comments on commit 00de276

Please sign in to comment.