mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-19 16:03:00 +00:00
BUG: Fix str/unicode warnings from SQLAlchemy on python 2.
When running with `reset_db=True` on python 2, several SQLAlchemy operations were performed with bytes where unicode was expected, resulting in warnings like the following. ``` /home/ssanderson/.virtualenvs/jupyterhub/local/lib/python2.7/site-packages/sqlalchemy/engine/default.py:573: SAWarning: Unicode type received non-unicodebind param value. param.append(processors[key](compiled_params[key])) ``` Fixes a few stray non-unicode literals and adds a unicode safe wrapper for `getpass.getuser`.
This commit is contained in:
@@ -4,9 +4,12 @@
|
||||
# Distributed under the terms of the Modified BSD License.
|
||||
|
||||
import binascii
|
||||
import getpass
|
||||
import errno
|
||||
import os
|
||||
import socket
|
||||
|
||||
from six import text_type
|
||||
from tornado import web, gen, ioloop
|
||||
from tornado.httpclient import AsyncHTTPClient, HTTPError
|
||||
from tornado.log import app_log
|
||||
@@ -21,6 +24,14 @@ except NameError:
|
||||
class TimeoutError(Exception):
|
||||
pass
|
||||
|
||||
|
||||
def getuser_unicode():
|
||||
"""
|
||||
Call getpass.getuser, ensuring that the output is returned as unicode.
|
||||
"""
|
||||
return text_type(getpass.getuser())
|
||||
|
||||
|
||||
def random_port():
|
||||
"""get a single random port"""
|
||||
sock = socket.socket()
|
||||
|
Reference in New Issue
Block a user