From 51040fb768417e26f898ac03b05456a1e30c7968 Mon Sep 17 00:00:00 2001 From: Thomas Kluyver Date: Wed, 23 Oct 2013 17:21:47 -0700 Subject: [PATCH] Update imports for Python 3 2to3 fixer imports (+ manual changes) --- IPython/html/base/zmqhandlers.py | 7 +++++-- IPython/utils/tests/test_io.py | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/IPython/html/base/zmqhandlers.py b/IPython/html/base/zmqhandlers.py index a552ba9c7..0d4c95af6 100644 --- a/IPython/html/base/zmqhandlers.py +++ b/IPython/html/base/zmqhandlers.py @@ -16,7 +16,10 @@ Authors: # Imports #----------------------------------------------------------------------------- -import Cookie +try: + from http.cookies import SimpleCookie # Py 3 +except ImportError: + from Cookie import SimpleCookie # Py 2 import logging from tornado import web from tornado import websocket @@ -102,7 +105,7 @@ class AuthenticatedZMQStreamHandler(ZMQStreamHandler, IPythonHandler): logging.error("First ws message didn't have the form 'identity:[cookie]' - %r", msg) try: - self.request._cookies = Cookie.SimpleCookie(msg) + self.request._cookies = SimpleCookie(msg) except: self.log.warn("couldn't parse cookie string: %s",msg, exc_info=True) diff --git a/IPython/utils/tests/test_io.py b/IPython/utils/tests/test_io.py index 2ece06818..c3a099ce6 100644 --- a/IPython/utils/tests/test_io.py +++ b/IPython/utils/tests/test_io.py @@ -15,7 +15,7 @@ from __future__ import print_function import sys -from StringIO import StringIO +from io import StringIO from subprocess import Popen, PIPE import unittest