diff --git a/contrib/make_status.py b/contrib/make_status.py index 2e23cf8324..31ab602782 100755 --- a/contrib/make_status.py +++ b/contrib/make_status.py @@ -30,13 +30,19 @@ def _pytidylib_version(): info = 'not installed' else: import ctypes - cdll = tidy._tidy - fn = cdll.tidyLibraryVersion - fn.restype = ctypes.c_char_p - libver = fn() - if isinstance(libver, bytes): - libver = str(libver, 'utf-8') - info = '%s %s' % (libver, cdll._name) + try: + cdll = tidy._tidy + try: + fn = cdll.tidyLibraryVersion + fn.restype = ctypes.c_char_p + libver = fn() + if isinstance(libver, bytes): + libver = str(libver, 'utf-8') + except Exception as e: + libver = repr(e) + info = '%s %s' % (libver, cdll._name) + except Exception as e: + info = repr(e) return '%s (%s)' % (version, info) if info else version def _pysqlite3_version(): diff --git a/trac/tests/functional/better_twill.py b/trac/tests/functional/better_twill.py index 8d1a58e8ac..aee512b495 100755 --- a/trac/tests/functional/better_twill.py +++ b/trac/tests/functional/better_twill.py @@ -40,10 +40,16 @@ except ImportError: selenium = None + +_tidy_options = { + 'escape-scripts': 0, + 'drop-empty-elements': 0, +} _curr = locale.setlocale(locale.LC_ALL, None) try: import tidylib - tidylib.tidy_document('') + tidylib.tidy_document('', + _tidy_options) except ImportError: print("SKIP: validation of HTML output in functional tests" " (no tidylib installed)") @@ -52,6 +58,9 @@ print("SKIP: validation of HTML output in functional tests" " (no tidy dynamic library installed: %s)" % e) tidy_document = None +except ValueError as e: + print("SKIP: validation of HTML output in functional tests (%r)" % e) + tidy_document = None else: if _curr == locale.setlocale(locale.LC_ALL, None): tidy_document = tidylib.tidy_document @@ -562,11 +571,6 @@ def _urljoin(self, url): url = urljoin(self.get_url(), url) return url - _tidy_options = { - 'escape-scripts': 0, - 'drop-empty-elements': 0, - } - _doctype_re = re.compile(r'\s*