From 3e842a7bf6e3b5479c9e110554c0399b461373a6 Mon Sep 17 00:00:00 2001 From: c-holtermann Date: Sat, 20 Jun 2020 10:35:31 +0200 Subject: [PATCH] use urllib.parse.urlparse to check for xml on python Session init --- bindings/python/gnucash_core.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bindings/python/gnucash_core.py b/bindings/python/gnucash_core.py index f5647c0121..2ef37911d4 100644 --- a/bindings/python/gnucash_core.py +++ b/bindings/python/gnucash_core.py @@ -29,6 +29,8 @@ # @ingroup python_bindings from enum import IntEnum +from urllib.parse import urlparse + from gnucash import gnucash_core_c from gnucash import _sw_core_utils @@ -228,7 +230,8 @@ class Session(GnuCashCoreClass): # Any existing store obviously has to be loaded # More background: https://bugs.gnucash.org/show_bug.cgi?id=726891 is_new = mode in (SessionOpenMode.SESSION_NEW_STORE, SessionOpenMode.SESSION_NEW_OVERWRITE) - if book_uri[:3] != "xml" or not is_new: + scheme = urlparse(book_uri).scheme + if not (is_new and scheme == 'xml'): self.load() except GnuCashBackendException as backend_exception: self.end()