[New-bugs-announce] [issue28727] Implement comparison (x==y and x!=y) for _sre.SRE_Pattern

STINNER Victor report at bugs.python.org
Thu Nov 17 11:02:48 EST 2016


New submission from STINNER Victor:

Attached patch implements rich comparison for _sre.SRE_Pattern objects created by re.compile().

Comparison between patterns is used in the warnings module to not add duplicated filters, see issue #18383:

New changeset f57f4e33ba5e by Martin Panter in branch '3.5':
Issue #18383: Avoid adding duplicate filters when warnings is reloaded
https://hg.python.org/cpython/rev/f57f4e33ba5e

For the warnings module, it became a problem in test_warnings since the Python test runner started to clear all caches. When re.purge() is called, re.compile() creates a new object, whereas with the cache it returns the same object and so the two patterns are equal since it's the same object. => see issue #28688

----------
files: pattern_compare.patch
keywords: patch
messages: 281046
nosy: haypo
priority: normal
severity: normal
status: open
title: Implement comparison (x==y and x!=y) for _sre.SRE_Pattern
type: enhancement
versions: Python 3.7
Added file: http://bugs.python.org/file45520/pattern_compare.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue28727>
_______________________________________


More information about the New-bugs-announce mailing list