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 <rep...@bugs.python.org>
<http://bugs.python.org/issue28727>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to