mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Windows: Edit book: Fix a crash when using the check book tool with a book that contains malformed markup. Fixes #2045133 [Editor closes immediately if epub-check finds parsing-failures in too much text-files](https://bugs.launchpad.net/calibre/+bug/2045133)
Bloody lxml doesnt initialize libxml2 correctly.
This commit is contained in:
parent
84d28a04db
commit
3596471257
@ -321,17 +321,17 @@
|
||||
{
|
||||
"name": "libxml2",
|
||||
"unix": {
|
||||
"filename": "libxml2-2.11.5.tar.xz",
|
||||
"hash": "sha256:3727b078c360ec69fa869de14bd6f75d7ee8d36987b071e6928d4720a28df3a6",
|
||||
"urls": ["https://download.gnome.org/sources/libxml2/2.11/{filename}"]
|
||||
"filename": "libxml2-2.12.1.tar.xz",
|
||||
"hash": "sha256:8982b9ccdf7f456e30d8f7012d50858c6623e495333b6191def455c7e95427eb",
|
||||
"urls": ["https://download.gnome.org/sources/libxml2/2.12/{filename}"]
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
"name": "libxslt",
|
||||
"unix": {
|
||||
"filename": "libxslt-1.1.38.tar.xz",
|
||||
"hash": "sha256:1f32450425819a09acaff2ab7a5a7f8a2ec7956e505d7beeb45e843d0e1ecab1",
|
||||
"filename": "libxslt-1.1.39.tar.xz",
|
||||
"hash": "sha256:2a20ad621148339b0759c4d4e96719362dee64c9a096dbba625ba053846349f0",
|
||||
"urls": ["https://download.gnome.org/sources/libxslt/1.1/{filename}"]
|
||||
}
|
||||
},
|
||||
|
@ -60,6 +60,16 @@ def set_quit():
|
||||
builtins.exit = _sitebuiltins.Quitter('exit', eof)
|
||||
|
||||
|
||||
def workaround_lxml_bug():
|
||||
# Without calling xmlInitParser() import lxml causes a segfault
|
||||
import ctypes
|
||||
x = ctypes.WinDLL('libxml2.dll')
|
||||
x.xmlInitParser()
|
||||
workaround_lxml_bug.libxml2 = x
|
||||
from lxml import etree
|
||||
del etree
|
||||
|
||||
|
||||
def main():
|
||||
sys.meta_path.insert(0, PydImporter())
|
||||
os.add_dll_directory(os.path.abspath(os.path.join(sys.app_dir, 'app', 'bin')))
|
||||
@ -75,6 +85,8 @@ def main():
|
||||
set_helper()
|
||||
set_quit()
|
||||
|
||||
workaround_lxml_bug()
|
||||
|
||||
return run_entry_point()
|
||||
|
||||
|
||||
|
@ -292,7 +292,7 @@ def check_xml_parsing(name, mt, raw):
|
||||
except XMLSyntaxError as err:
|
||||
try:
|
||||
line, col = err.position
|
||||
except:
|
||||
except Exception:
|
||||
line = col = None
|
||||
return errors + [errcls(error_message(err), name, line, col)]
|
||||
except Exception as err:
|
||||
|
Loading…
x
Reference in New Issue
Block a user