Avoid conversion, match only ASCII numbers

This commit is contained in:
int3l 2019-11-24 01:43:08 +02:00 committed by GitHub
parent d4c565fea9
commit aa9c6983bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

4
bot.py
View File

@ -295,11 +295,11 @@ def cmd_uptime(match: Match[str]) -> Response:
return UptimeResponse()
@handle_message(r'!pep[ ]?(?P<pep_num>\d{1,4})')
@handle_message(r'!pep[ ]?(?P<pep_num>\d{1,4})', flags=re.ASCII)
def cmd_pep(match: Match[str]) -> Response:
*_, number = match.groups()
return MessageResponse(
match, f'https://www.python.org/dev/peps/pep-{int(number).zfill(4)}/',
match, f'https://www.python.org/dev/peps/pep-{number.zfill(4)}/',
)