Issue 1282: re module needs to support bytes / memoryview well (original) (raw)
Issue1282
Created on 2007-10-15 23:26 by gvanrossum, last changed 2022-04-11 14:56 by admin. This issue is now closed.
Messages (5) | ||
---|---|---|
msg56472 - (view) | Author: Guido van Rossum (gvanrossum) * ![]() |
Date: 2007-10-15 23:26 |
Once PEP 3137 is fully implemented, the re module needs to be fixed so that the regex argument, the substitution argument, and the argument being searched/replaced are allowed to be arbitrary bytes arrays; where hashing is needed a copy in an immutable bytes object can be made. | ||
msg82582 - (view) | Author: Benjamin Peterson (benjamin.peterson) * ![]() |
Date: 2009-02-21 21:05 |
re has supported bytes for a while now. | ||
msg230855 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * ![]() |
Date: 2014-11-08 13:16 |
Actually non-hashable patterns are not supported. >>> re.match(bytearray(b'.'), b'x') Traceback (most recent call last): File "", line 1, in File "/home/serhiy/py/cpython/Lib/re.py", line 163, in match return _compile(pattern, flags).match(string) File "/home/serhiy/py/cpython/Lib/re.py", line 281, in _compile p, loc = _cache[type(pattern), pattern, flags] TypeError: unhashable type: 'bytearray' Should it be considered as a bug? | ||
msg230872 - (view) | Author: Guido van Rossum (gvanrossum) * ![]() |
Date: 2014-11-08 18:04 |
Hm, I don't see a reason why the *pattern* should be a bytearray or memoryview, only the string it is searching. But if you fixed it by casting it to bytes I won't stop you. :-) | ||
msg230874 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * ![]() |
Date: 2014-11-08 20:27 |
It is easy to fix with small (but non zero) cost, but I don't see a reason too. So I don't reopen this issue. |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-11 14:56:27 | admin | set | github: 45623 |
2014-11-08 20:27:32 | serhiy.storchaka | set | messages: + |
2014-11-08 18:04:49 | gvanrossum | set | messages: + |
2014-11-08 13:16:22 | serhiy.storchaka | set | nosy: + serhiy.storchakamessages: + |
2009-02-21 21:05:47 | benjamin.peterson | set | status: open -> closednosy: + benjamin.petersonresolution: accepted -> out of datemessages: + |
2008-09-28 19:26:58 | timehorse | set | nosy: + timehorse |
2008-01-06 22:29:45 | admin | set | keywords: - py3kversions: Python 3.0 |
2007-11-24 14:17:23 | georg.brandl | set | type: enhancement -> behavior |
2007-11-08 14:52:51 | christian.heimes | set | priority: normaltype: enhancementresolution: acceptedkeywords: + py3k |
2007-10-15 23:26:51 | gvanrossum | create |