Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecation warnings on Python 3.7 #31

Closed
jugmac00 opened this issue Jan 13, 2020 · 5 comments · Fixed by #39
Closed

Deprecation warnings on Python 3.7 #31

jugmac00 opened this issue Jan 13, 2020 · 5 comments · Fixed by #39

Comments

@jugmac00
Copy link
Contributor

/home/jugmac00/Projects/bliss_deployment/work/_/home/jugmac00/.batou-shared-eggs/python_creole-1.3.2-py3.7.egg/creole/parser/creol2html_parser.py:48
  /home/jugmac00/Projects/bliss_deployment/work/_/home/jugmac00/.batou-shared-eggs/python_creole-1.3.2-py3.7.egg/creole/parser/creol2html_parser.py:48: DeprecationWarning: Flags not at the start of the expression '(?P<image>\n         ' (truncated)
    re.VERBOSE | re.UNICODE

/home/jugmac00/Projects/bliss_deployment/work/_/home/jugmac00/.batou-shared-eggs/python_creole-1.3.2-py3.7.egg/creole/parser/creol2html_parser.py:56
  /home/jugmac00/Projects/bliss_deployment/work/_/home/jugmac00/.batou-shared-eggs/python_creole-1.3.2-py3.7.egg/creole/parser/creol2html_parser.py:56: DeprecationWarning: Flags not at the start of the expression '\n            \\| \\s*\n' (truncated)
    cell_re = re.compile(SpecialRules.cell, re.VERBOSE | re.UNICODE)

/home/jugmac00/Projects/bliss_deployment/work/_/home/jugmac00/.batou-shared-eggs/python_creole-1.3.2-py3.7.egg/creole/parser/creol2html_parser.py:59
  /home/jugmac00/Projects/bliss_deployment/work/_/home/jugmac00/.batou-shared-eggs/python_creole-1.3.2-py3.7.egg/creole/parser/creol2html_parser.py:59: DeprecationWarning: Flags not at the start of the expression '(?P<link>\n          ' (truncated)
    inline_re = re.compile('|'.join(INLINE_RULES), INLINE_FLAGS)
@jedie
Copy link
Owner

jedie commented Jan 19, 2020

One of these have i fixed with 97acbc4#diff-7e85869c19954199a320efc15b208cb9

But two still exists. But i haven't find the wrong regexp :(

@jugmac00
Copy link
Contributor Author

These are really tough ones! Especially as the deprecation warning is truncated.

I patchted CPython in sre_parse.py (at the line with Flags not at the start of the expression) and now I get the full deprecation warning:

creole/parser/creol2html_parser.py:51
  /home/jugmac00/Projects/python-creole/creole/parser/creol2html_parser.py:51: DeprecationWarning: Flags not at the start of the expression '\n            \\| \\s*\n            (\n                (?P<head> [=][^|]+ ) |\n                (?P<cell> (  (?P<link>\n            \\[\\[\n            (?P<link_target>.+?) \\s*\n            ([|] \\s* (?P<link_text>.+?) \\s*)?\n            ]]\n        )|\n        (?P<macro_inline>\n        << \\s* (?P<macro_inline_start>\\w+) \\s* (?P<macro_inline_args>.*?) \\s* >>\n        (?P<macro_inline_text>(.|\\n)*?)\n        <</ \\s* (?P=macro_inline_start) \\s* >>\n        )\n    |(?P<macro_tag>\n            <<(?P<macro_tag_name> \\w+) (?P<macro_tag_args>.*?) \\s* /*>>\n        )|(?i)(?P<image>\n            {{\n            (?P<image_target>.+?) \\s*\n            (\\| \\s* (?P<image_text>.+?) \\s*)?\n            }}\n        )|(?P<pre_inline> {{{ (?P<pre_inline_text>.*?) }}} ) | [^|])+ )\n            ) \\s*\n        '
    cell_re = re.compile(x, re.VERBOSE | re.UNICODE)

creole/parser/creol2html_parser.py:55
  /home/jugmac00/Projects/python-creole/creole/parser/creol2html_parser.py:55: DeprecationWarning: Flags not at the start of the expression '(?P<link>\n            \\[\\[\n            (?P<link_target>.+?) \\s*\n            ([|] \\s* (?P<link_text>.+?) \\s*)?\n            ]]\n        )|(?P<url>\n            (^ | (?<=\\s))\n            (?P<escaped_url>~)?\n            (?P<url_target> (?P<url_proto> http|https|ftp|nntp|news|mailto|telnet|file|irc )://[^$\\s]+ )\n        )|\n        (?P<macro_inline>\n        << \\s* (?P<macro_inline_start>\\w+) \\s* (?P<macro_inline_args>.*?) \\s* >>\n        (?P<macro_inline_text>(.|\\n)*?)\n        <</ \\s* (?P=macro_inline_start) \\s* >>\n        )\n    |(?P<macro_tag>\n            <<(?P<macro_tag_name> \\w+) (?P<macro_tag_args>.*?) \\s* /*>>\n        )|(?P<pre_inline> {{{ (?P<pre_inline_text>.*?) }}} )|(?i)(?P<image>\n            {{\n            (?P<image_target>.+?) \\s*\n            (\\| \\s* (?P<image_text>.+?) \\s*)?\n            }}\n        )|(?P<strong>\\*\\* (?P<strong_text>.+?) \\*\\* )|(?P<emphasis>(?<!:)// (?P<emphasis_text>.+?) (?<!:)// )|(?P<monospace> \\#\\# (?P<monospace_text>.+?) \\#\\# )|(?P<underline> __ (?P<underline_text>.+?) __ )|(?P<superscript> \\^\\^ (?P<superscript_text>.+?) \\^\\^ )|(?P<subscript> ,, (?P<subscript_text>.+?) ,, )|(?P<small>-- (?P<small_text>.+?) -- )|(?P<delete> ~~ (?P<delete_text>.+?) ~~ )|(?P<linebreak> \\\\\\\\ )|(?P<escape> ~ (?P<escaped_char>\\S) )|(?P<char> . )'
    inline_re = re.compile('|'.join(INLINE_RULES), INLINE_FLAGS)

So it seems it is the ?i flag.

When I remove the flag from InlineRules.image (just for debugging) indeed I get no more deprecation warnings from regex.

As a side note - the tests still pass - so either this flag is not needed at all, or the tests miss a special test case.

Does this help you? Unfortunately, I rarely work with regexes, and especially not with complex ones as here. Without further studying I cannot help here.

@jedie
Copy link
Owner

jedie commented Jan 20, 2020

remove the flag from InlineRules.image

(?i) is re.IGNORECASE so it can be removed, see also: 97acbc4#commitcomment-36877309

jedie added a commit that referenced this issue Jan 20, 2020
(?i) is re.IGNORECASE
The image tag doesn't contain anything that must match case-insensitive. So it can be removed, to fix: #31
@jedie jedie closed this as completed in #39 Jan 20, 2020
@jedie
Copy link
Owner

jedie commented Jan 20, 2020

Removed with #39 ... Can you confirm?

@jugmac00
Copy link
Contributor Author

Indeed, the deprecation warnings are gone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants