summaryrefslogtreecommitdiff
path: root/dev-python/lxml/files
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--dev-python/lxml/files/gtk-threading-filename-guessing.patch35
-rw-r--r--dev-python/lxml/files/parse-gtk-problem.patch45
2 files changed, 80 insertions, 0 deletions
diff --git a/dev-python/lxml/files/gtk-threading-filename-guessing.patch b/dev-python/lxml/files/gtk-threading-filename-guessing.patch
new file mode 100644
index 0000000..a48f258
--- /dev/null
+++ b/dev-python/lxml/files/gtk-threading-filename-guessing.patch
@@ -0,0 +1,35 @@
+=== src/lxml/apihelpers.pxi
+==================================================================
+--- src/lxml/apihelpers.pxi (revision 3804)
++++ src/lxml/apihelpers.pxi (revision 3805)
+@@ -1107,20 +1107,16 @@
+ Returns None if not a file object.
+ """
+ # file instances have a name attribute
+- try:
+- return source.name
+- except AttributeError:
+- pass
++ filename = getattr3(source, 'name', None)
++ if filename is not None:
++ return filename
+ # gzip file instances have a filename attribute
+- try:
+- return source.filename
+- except AttributeError:
+- pass
++ filename = getattr3(source, 'filename', None)
++ if filename is not None:
++ return filename
+ # urllib2 provides a geturl() method
+- try:
+- geturl = source.geturl
+- except AttributeError:
+- # can't determine filename
+- return None
+- else:
++ geturl = getattr3(source, 'geturl', None)
++ if geturl is not None:
+ return geturl()
++ # can't determine filename
++ return None
diff --git a/dev-python/lxml/files/parse-gtk-problem.patch b/dev-python/lxml/files/parse-gtk-problem.patch
new file mode 100644
index 0000000..e8aafdf
--- /dev/null
+++ b/dev-python/lxml/files/parse-gtk-problem.patch
@@ -0,0 +1,45 @@
+=== src/lxml/parser.pxi
+==================================================================
+--- src/lxml/parser.pxi (revision 3798)
++++ src/lxml/parser.pxi (revision 3799)
+@@ -1294,10 +1294,22 @@
+
+ cdef _Document _parseDocument(source, _BaseParser parser, base_url):
+ cdef _Document doc
++ if _isString(source):
++ # parse the file directly from the filesystem
++ doc = _parseDocumentFromURL(_encodeFilename(source), parser)
++ # fix base URL if requested
++ if base_url is not None:
++ base_url = _encodeFilenameUTF8(base_url)
++ if doc._c_doc.URL is not NULL:
++ tree.xmlFree(doc._c_doc.URL)
++ doc._c_doc.URL = tree.xmlStrdup(_cstr(base_url))
++ return doc
++
+ if base_url is not None:
+ url = base_url
+ else:
+ url = _getFilenameForFile(source)
++
+ if hasattr(source, 'getvalue') and hasattr(source, 'tell'):
+ # StringIO - reading from start?
+ if source.tell() == 0:
+@@ -1309,16 +1321,7 @@
+ return _parseFilelikeDocument(
+ source, _encodeFilenameUTF8(url), parser)
+
+- # Otherwise parse the file directly from the filesystem
+- filename = _encodeFilename(source)
+- doc = _parseDocumentFromURL(filename, parser)
+- # fix base URL if requested
+- if base_url is not None:
+- base_url = _encodeFilenameUTF8(base_url)
+- if doc._c_doc.URL is not NULL:
+- tree.xmlFree(doc._c_doc.URL)
+- doc._c_doc.URL = tree.xmlStrdup(_cstr(base_url))
+- return doc
++ raise TypeError("cannot parse from '%s'" % python._fqtypename(source))
+
+ cdef _Document _parseDocumentFromURL(url, _BaseParser parser):
+ cdef xmlDoc* c_doc