[Libreoffice-commits] .: python/makefile.mk python/Python-2.6.1-urllib.patch

Petr Mladek pmladek at kemper.freedesktop.org
Tue Nov 23 09:38:44 PST 2010


 python/Python-2.6.1-urllib.patch |   93 +++++++++++++++++++++++++++++++++++++++
 python/makefile.mk               |    3 -
 2 files changed, 95 insertions(+), 1 deletion(-)

New commits:
commit 93c0b49f6d86559a5f0fb9dd859ab04c5545aee9
Author: Petr Mladek <pmladek at suse.cz>
Date:   Tue Nov 23 18:31:36 2010 +0100

    fixed urllib.urlopen in the internal python (fdo#31466)
    
    + backported two fixes from newer python:
        + close the file even if an exception occurs (py#5536)
        + urllib doesn't correct server returned urls (py#918368)
    + thanks karolus <karlooforum at arcor dot de> for analyzing and suggesting
      the fix

diff --git a/python/Python-2.6.1-urllib.patch b/python/Python-2.6.1-urllib.patch
new file mode 100644
index 0000000..6e20390
--- /dev/null
+++ b/python/Python-2.6.1-urllib.patch
@@ -0,0 +1,93 @@
+--- misc/Python-2.6.1/Lib/urllib.py	2008-09-21 23:27:51.000000000 +0200
++++ misc/build/Python-2.6.1/Lib/urllib.py	2010-11-23 15:41:08.000000000 +0100
+@@ -176,6 +176,9 @@ class URLopener:
+     def open(self, fullurl, data=None):
+         """Use URLopener().open(file) instead of open(file, 'r')."""
+         fullurl = unwrap(toBytes(fullurl))
++         # percent encode url. fixing lame server errors like space within url
++        # parts
++        fullurl = quote(fullurl, safe="%/:=&?~#+!$,;'@()*[]|")       
+         if self.tempcache and fullurl in self.tempcache:
+             filename, headers = self.tempcache[fullurl]
+             fp = open(filename, 'rb')
+@@ -233,41 +236,45 @@ class URLopener:
+             except IOError, msg:
+                 pass
+         fp = self.open(url, data)
+-        headers = fp.info()
+-        if filename:
+-            tfp = open(filename, 'wb')
+-        else:
+-            import tempfile
+-            garbage, path = splittype(url)
+-            garbage, path = splithost(path or "")
+-            path, garbage = splitquery(path or "")
+-            path, garbage = splitattr(path or "")
+-            suffix = os.path.splitext(path)[1]
+-            (fd, filename) = tempfile.mkstemp(suffix)
+-            self.__tempfiles.append(filename)
+-            tfp = os.fdopen(fd, 'wb')
+-        result = filename, headers
+-        if self.tempcache is not None:
+-            self.tempcache[url] = result
+-        bs = 1024*8
+-        size = -1
+-        read = 0
+-        blocknum = 0
+-        if reporthook:
+-            if "content-length" in headers:
+-                size = int(headers["Content-Length"])
+-            reporthook(blocknum, bs, size)
+-        while 1:
+-            block = fp.read(bs)
+-            if block == "":
+-                break
+-            read += len(block)
+-            tfp.write(block)
+-            blocknum += 1
+-            if reporthook:
+-                reporthook(blocknum, bs, size)
+-        fp.close()
+-        tfp.close()
++        try:
++            headers = fp.info()
++            if filename:
++                tfp = open(filename, 'wb')
++            else:
++                import tempfile
++                garbage, path = splittype(url)
++                garbage, path = splithost(path or "")
++                path, garbage = splitquery(path or "")
++                path, garbage = splitattr(path or "")
++                suffix = os.path.splitext(path)[1]
++                (fd, filename) = tempfile.mkstemp(suffix)
++                self.__tempfiles.append(filename)
++                tfp = os.fdopen(fd, 'wb')
++            try:
++                result = filename, headers
++                if self.tempcache is not None:
++                    self.tempcache[url] = result
++                bs = 1024*8
++                size = -1
++                read = 0
++                blocknum = 0
++                if reporthook:
++                    if "content-length" in headers:
++                        size = int(headers["Content-Length"])
++                    reporthook(blocknum, bs, size)
++                while 1:
++                    block = fp.read(bs)
++                    if block == "":
++                        break
++                    read += len(block)
++                    tfp.write(block)
++                    blocknum += 1
++                    if reporthook:
++                        reporthook(blocknum, bs, size)
++            finally:
++                tfp.close()
++        finally:
++            fp.close()
+         del fp
+         del tfp
+ 
diff --git a/python/makefile.mk b/python/makefile.mk
index 6f4b7ee..d090cdc 100644
--- a/python/makefile.mk
+++ b/python/makefile.mk
@@ -50,7 +50,8 @@ TARFILE_MD5=e81c2f0953aa60f8062c05a4673f2be0
 PATCH_FILES=\
     Python-$(PYVERSION).patch \
     Python-ssl.patch \
-    Python-aix.patch
+    Python-aix.patch \
+    Python-2.6.1-urllib.patch
 
 CONFIGURE_DIR=
 


More information about the Libreoffice-commits mailing list