From a43fb5760be88c5e04fd40994642f2b3199ec163 Mon Sep 17 00:00:00 2001 From: Ekevoo Date: Fri, 18 Sep 2015 02:42:36 -0400 Subject: [PATCH] py2: urllib cross compatibility hack --- pyoneall/connection.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pyoneall/connection.py b/pyoneall/connection.py index 4c62743..5cb9d71 100644 --- a/pyoneall/connection.py +++ b/pyoneall/connection.py @@ -1,13 +1,19 @@ # -*- coding: utf-8 -*- from __future__ import absolute_import, division, print_function, unicode_literals + +try: + from urllib.error import HTTPError + from urllib.request import Request, urlopen +except ImportError: + # https://github.com/PythonCharmers/python-future/issues/167 + from urllib2 import HTTPError, Request, urlopen + from future import standard_library standard_library.install_aliases() from base64 import standard_b64encode from json import dumps, loads -from urllib.error import HTTPError -from urllib.request import Request, urlopen from .base import OADict from .classes import Users, Connections, Connection, User, BadOneAllCredentials