Re: [PATCH] docs: sphinx: handle removeal of utils.error_reporting in docutils 0.22

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Zhixu Liu <zhixu.liu@xxxxxxxxx> writes:

> docutils.utils.error_reporting wass removed in docutils v0.22, causing sphinx
> extension (kernel_include) to fail with:
>
>>   File "/usr/lib/python3.12/site-packages/sphinx/registry.py", line 544, in load_extension
>>     raise ExtensionError(
>> sphinx.errors.ExtensionError: Could not import extension kernel_include (exception: No module named 'docutils.utils.error_reporting')
>
> add compatibility handling with try/except:
> - SafeString → str
> - ErrorString → docutils.io.error_string()
>
> Signed-off-by: Z. Liu <zhixu.liu@xxxxxxxxx>
> ---
>  Documentation/sphinx/kernel_feat.py         | 5 ++++-
>  Documentation/sphinx/kernel_include.py      | 6 +++++-
>  Documentation/sphinx/maintainers_include.py | 5 ++++-
>  3 files changed, 13 insertions(+), 3 deletions(-)
>
> diff --git a/Documentation/sphinx/kernel_feat.py
> b/Documentation/sphinx/kernel_feat.py
> index e3a51867f27bd..95f852c0722e1 100644
> --- a/Documentation/sphinx/kernel_feat.py
> +++ b/Documentation/sphinx/kernel_feat.py
> @@ -40,7 +40,10 @@ import sys
>  from docutils import nodes, statemachine
>  from docutils.statemachine import ViewList
>  from docutils.parsers.rst import directives, Directive
> -from docutils.utils.error_reporting import ErrorString
> +try:
> +    from docutils.utils.error_reporting import ErrorString
> +except:
> +    from docutils.io import error_string as ErrorString
>  from sphinx.util.docutils import switch_source_input

I really hate to see bare except: statements in Python code; they hide
bugs far too easily.  If we have to do it this way, please catch the
ExtensionError exception explicitly.

But can we do this in a more straightforward way looking at the docutils
version?  That would make what's going on a lot clearer.

Thanks,

jon





[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux