Commit 463123e4 authored by Jérome Perrin's avatar Jérome Perrin Committed by Arnaud Fontaine

core: fix Flags not at the start of the expression warnings with new mimetypes_registry

parent 61ffeb94
Pipeline #37042 failed with stage
in 0 seconds
This source diff could not be displayed because it is too large. You can view the blob instead.
  • --- 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 ?

  • 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.

  • mentioned in commit b819f8da

    Toggle commit list
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment