(self, fullurl, data=None)
Use URLopener().open(file) instead of open(file, 'r').
Use URLopener().open(file) instead of open(file, 'r').
Use URLopener () . open ( file ) instead of open ( file r ) .
def open(self, fullurl, data=None):
        """Use URLopener().open(file) instead of open(file, 'r')."""
        fullurl = unwrap(_to_bytes(fullurl))
        fullurl = quote(fullurl, safe="%/:=&?~#+!$,;'@()*[]|")
        if self.tempcache and fullurl in self.tempcache:
            filename, headers = self.tempcache[fullurl]
            fp = open(filename, 'rb')
            return addinfourl(fp, headers, fullurl)
        urltype, url = _splittype(fullurl)
        if not urltype:
            urltype = 'file'
        if urltype in self.proxies:
            proxy = self.proxies[urltype]
            urltype, proxyhost = _splittype(proxy)
            host, selector = _splithost(proxyhost)
            url = (host, fullurl) # Signal special case to open_*()
        else:
            proxy = None
        name = 'open_' + urltype
        self.type = urltype
        name = name.replace('-', '_')
        if not hasattr(self, name) or name == 'open_local_file':
            if proxy:
                return self.open_unknown_proxy(proxy, fullurl, data)
            else:
                return self.open_unknown(fullurl, data)
        try:
            if data is None:
                return getattr(self, name)(url)
            else:
                return getattr(self, name)(url, data)
        except (HTTPError, URLError):
            raise
        except OSError as msg:
            raise OSError('socket error', msg).with_traceback(sys.exc_info()[2])
def open ( self , fullurl , data = None ) : fullurl = unwrap ( _to_bytes ( fullurl ) ) fullurl = quote ( fullurl , safe = "%/:=&?~#+!$,;'@()*[]|" ) if self . tempcache and fullurl in self . tempcache : filename , headers = self . tempcache [ fullurl ] fp = open ( filename , 'rb' ) return addinfourl ( fp , headers , fullurl ) urltype , url = _splittype ( fullurl ) if not urltype : urltype = 'file' if urltype in self . proxies : proxy = self . proxies [ urltype ] urltype , proxyhost = _splittype ( proxy ) host , selector = _splithost ( proxyhost ) url = ( host , fullurl ) # Signal special case to open_*() else : proxy = None name = 'open_' + urltype self . type = urltype name = name . replace ( '-' , '_' ) if not hasattr ( self , name ) or name == 'open_local_file' : if proxy : return self . open_unknown_proxy ( proxy , fullurl , data ) else : return self . open_unknown ( fullurl , data ) try : if data is None : return getattr ( self , name ) ( url ) else : return getattr ( self , name ) ( url , data ) except ( HTTPError , URLError ) : raise except OSError as msg : raise OSError ( 'socket error' , msg ) . with_traceback ( sys . exc_info ( ) [ 2 ] )