New submission from Quentin Wenger <[email protected]>:
I noticed that match.groupdict() returns string keys, even for a bytes regex:
```
>>> import re
>>> re.match(b"(?P<a>)", b"").groupdict()
{'a': b''}
```
This seems somewhat strange, because string and bytes matching in re are kind
of two separate parts, cf. doc:
> Both patterns and strings to be searched can be Unicode strings (str) as well
> as 8-bit strings (bytes). However, Unicode strings and 8-bit strings cannot
> be mixed: that is, you cannot match a Unicode string with a byte pattern or
> vice-versa; similarly, when asking for a substitution, the replacement string
> must be of the same type as both the pattern and the search string.
----------
components: Regular Expressions
messages: 371516
nosy: ezio.melotti, matpi, mrabarnett
priority: normal
severity: normal
status: open
title: group names of bytes regexes are strings
type: behavior
versions: Python 3.8
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue40980>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com