From f1332c9e1abb5aa8f73414559eb321104f60b835 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Fri, 22 Mar 2013 01:28:56 +0000 Subject: [PATCH] Conditionalize where urlopen comes from for Py2/Py3 git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@73697 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- wx/lib/softwareupdate.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/wx/lib/softwareupdate.py b/wx/lib/softwareupdate.py index e946bd9c..fd88f96f 100644 --- a/wx/lib/softwareupdate.py +++ b/wx/lib/softwareupdate.py @@ -10,6 +10,8 @@ # RCS-ID: $Id$ # Copyright: (c) 2011 by Total Control Software # Licence: wxWindows license +# +# Tags: py3-port?? #---------------------------------------------------------------------- """ @@ -29,7 +31,14 @@ import wx import sys import os import atexit -import urllib2 +import wx.lib.six as six + +if six.PY3: + from urllib.request import urlopen + from urllib.error import URLError +else: + from urllib2 import urlopen + from urllib2 import URLError from wx.lib.dialogs import MultiMessageBox @@ -148,12 +157,12 @@ class SoftwareUpdate(object): newest = self._esky.find_update() chLogTxt = '' if newest is not None and self._changelogURL: - req = urllib2.urlopen(self._changelogURL, timeout=4) + req = urlopen(self._changelogURL, timeout=4) chLogTxt = req.read() req.close() return (newest, chLogTxt) - except urllib2.URLError: + except URLError: return 'URLError'