Browse Source

Fix DeprecationWarning in escape_markdown()

Using `count` as positional argument to `re.sub` is deprecated since
Python 3.13.

Fixes #10490
master
Niklas Mertsch 2 weeks ago
committed by GitHub
parent
commit
1add8a0b40
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 2
      discord/utils.py

2
discord/utils.py

@ -1008,7 +1008,7 @@ def escape_markdown(text: str, *, as_needed: bool = False, ignore_links: bool =
regex = _MARKDOWN_STOCK_REGEX
if ignore_links:
regex = f'(?:{_URL_REGEX}|{regex})'
return re.sub(regex, replacement, text, 0, re.MULTILINE)
return re.sub(regex, replacement, text, count=0, flags=re.MULTILINE)
else:
text = re.sub(r'\\', r'\\\\', text)
return _MARKDOWN_ESCAPE_REGEX.sub(r'\\\1', text)

Loading…
Cancel
Save