STINNER Victor added the comment:

Serhiy: "There is a problem with locale-depending flags. The same pattern may 
be compiled with the LOCALE flag to different pattern objects in different 
locales."

Oh, I didn't know and you are right.

"Perhaps we should compare the compiled code instead of pattern strings. Or 
both."

PatternObject contains many fields. I used the following two fields which come 
from re.compile():

* pattern
* flags

I considered that they were enough because pattern_repr() only displays these 
ones. Other fields:

* groups
* groupindex
* indexgroup
* weakreflist
* isbytes
* codesize, code

weakreflist can be skipped, isbytes is already tested in my patch.

Would it be possible to only compare code instead of pattern? What are groups, 
groupindex and indexgroup: should we also compare them?

Maybe I can start from  pattern_compare-4.patch and only add a test comparing 
code?

----------

_______________________________________
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