core: fix Flags not at the start of the expression warnings with new mimetypes_registry
Showing
This source diff could not be displayed because it is too large. You can view the blob instead.
-
Owner
--- product/ERP5/bootstrap/erp5_core/ToolTemplateItem/mimetypes_registry.xml +++ product/ERP5/bootstrap/erp5_core/ToolTemplateItem/mimetypes_registry.xml @@ -73530,7 +73530,7 @@ <global id="1207.1" name="_compile" module="re"/> </klass> <tuple> - <unicode>.*\\%\\Z(?ms)</unicode> + <unicode>(?ms).*\\%\\Z</unicode> <int>24</int> </tuple> </object>
@jerome this comes from the code in MimetypesRegistry.py
def register_glob(self, glob, mimetype): ... pattern = re.compile(fnmatch.translate(glob))
In py2:
>>> fnmatch.translate('*.aaa') '.*\\.aaa\\Z(?ms)'
In py3:
>>> fnmatch.translate('*.aaa') '(?s:.*\\.aaa)\\Z'
and boths are incompatible in the other...
py3 result in py2
>>> re.compile('(?s:.*\\.aaa)\\Z') ... error: unknown extension
py2 result in py3
>>> re.compile('.*\\.aaa\\Z(?ms)') ... re.error: global flags not at the start of the expression at position 9
What can we do to prevent this kind of commit again and again ?
-
Owner
Thanks for investigating. I don't see a solution for this. This does not look extremely bad, because for now, we can manually edit the .xml like I did after we update mimetypes and we don't update mimetypes too often.
I suggest we push this commit in master, with your explanation about where it comes from and also an explanation about how I made this commit.
Please register or sign in to comment