From 49ab23db0b68e590b2c98a9c1390cda3dc7a514d Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Thu, 31 May 2018 12:39:17 +0900 Subject: [PATCH] Fix #5022: latex: crashed with docutils package provided by Debian/Ubuntu --- CHANGES | 1 + sphinx/writers/latex.py | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 14272aeb1..dcb1b581e 100644 --- a/CHANGES +++ b/CHANGES @@ -20,6 +20,7 @@ Bugs fixed * sphinx.testing uses deprecated pytest API; ``Node.get_marker(name)`` * #5016: ``character_level_inline_markup`` setting is not initialized for combination of non reST source parsers (ex. recommonmark) and docutils-0.13 +* #5022: latex: crashed with docutils package provided by Debian/Ubuntu Testing -------- diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py index 0e5462ea2..941181d0a 100644 --- a/sphinx/writers/latex.py +++ b/sphinx/writers/latex.py @@ -18,7 +18,6 @@ from collections import defaultdict from os import path from docutils import nodes, writers -from docutils.utils.roman import toRoman from docutils.writers.latex2e import Babel from six import itervalues, text_type @@ -32,6 +31,12 @@ from sphinx.util.nodes import clean_astext from sphinx.util.template import LaTeXRenderer from sphinx.util.texescape import tex_escape_map, tex_replace_map +try: + from docutils.utils.roman import toRoman +except ImportError: + # In Debain/Ubuntu, roman package is provided as roman, not as docutils.utils.roman + from roman import toRoman + if False: # For type annotation from typing import Any, Callable, Dict, Iterator, List, Pattern, Tuple, Set, Union # NOQA