[Python-modules-team] Bug#979225: mistune: deprecation warning with Python 3.9

Julian Gilbey jdg at debian.org
Tue Jan 5 06:41:30 GMT 2021


On Mon, Jan 04, 2021 at 11:55:52AM +0000, Julian Gilbey wrote:
> Package: python3-mistune
> Version: 0.8.4-4
> Severity: normal
> Tags: upstream
> 
> This deprecation warning appears with Python 3.9:
> 
> /usr/lib/python3/dist-packages/mistune.py:435: DeprecationWarning: invalid escape sequence \|
>     cells[i][c] = re.sub('\\\\\|', '|', cell)
> 
> I'm not sure what is intended here; perhaps
>     cells[i][c] = re.sub(r'\|', '|', cell)
> 
> Best wishes,
> 
>    Julian

Ah, no, that makes no sense.  I think there's just a missing backslash
in the first, so the correct line should be

     cells[i][c] = re.sub('\\\\\\|', '|', cell)

or more readably:

     cells[i][c] = re.sub(r'\\\|', '|', cell)

Of course a simpler solution is

     cells[i][c] = cell.replace(r'\|', '|')

Best wishes,

   Julian



More information about the Python-modules-team mailing list