Ticket #9157 (closed defect: fixed)

Opened 2 years ago

Last modified 8 months ago

ValueError: Cannot process flags argument with a compiled pattern (when displaying markdown)

Reported by: peerst Assigned to: dwclifton
Priority: normal Component: MarkdownMacro
Severity: normal Keywords:
Cc: hasienda Trac Release: 0.12

Description

Just installed the extension and when trying it out (with a ticket that contains the example on the MarkdownMacro page I get the following error:

File "/var/tmp/trac-test/egg-cache/Trac-0.12.2-py2.7.egg-tmp/trac/ticket/templates/ticket_box.html", line 77, in <Expression u'wiki_to_html(context, ticket.description, escape_newlines=preserve_newlines)'>
  ${wiki_to_html(context, ticket.description, escape_newlines=preserve_newlines)}
File "build/bdist.freebsd-8.2-RELEASE-amd64/egg/trac/wiki/formatter.py", line 1497, in format_to_html
  return HtmlFormatter(env, context, wikidom).generate(escape_newlines)
File "build/bdist.freebsd-8.2-RELEASE-amd64/egg/trac/wiki/formatter.py", line 1452, in generate
  escape_newlines)
File "build/bdist.freebsd-8.2-RELEASE-amd64/egg/trac/wiki/formatter.py", line 1201, in format
  self.handle_code_block(line, block_start_match)
File "build/bdist.freebsd-8.2-RELEASE-amd64/egg/trac/wiki/formatter.py", line 1091, in handle_code_block
  processed = self.code_processor.process(code_text)
File "build/bdist.freebsd-8.2-RELEASE-amd64/egg/trac/wiki/formatter.py", line 304, in process
  text = self.processor(text)
File "build/bdist.freebsd-8.2-RELEASE-amd64/egg/trac/wiki/formatter.py", line 291, in _macro_processor
  text)
File "build/bdist.freebsd-8.2-RELEASE-amd64/egg/Markdown/macro.py", line 60, in expand_macro
  return markdown(sub(LINK, convert, content))
File "/usr/local/lib/python2.7/re.py", line 151, in sub
  return _compile(pattern, flags).sub(repl, string, count)
File "build/bdist.freebsd-8.2-RELEASE-amd64/egg/Markdown/macro.py", line 51, in convert
  I).groups()[0]
File "/usr/local/lib/python2.7/re.py", line 142, in search
  return _compile(pattern, flags).search(string)
File "/usr/local/lib/python2.7/re.py", line 237, in _compile
  raise ValueError('Cannot process flags argument with a compiled pat

System Information:

User Agent: Mozilla/5.0 (Macintosh; PPC Mac OS X 10_5_8) AppleWebKit/534.50.2 (KHTML, like Gecko) Version/5.0.6 Safari/533.22.3

Trac	0.12.2
Babel	0.9.6
Docutils	0.8
Genshi	0.6
Mercurial	1.9.1
Pygments	1.4
pysqlite	2.6.0
Python	2.7.2 (default, Sep 2 2011, 10:31:59) [GCC 4.2.1 20070719 [FreeBSD]]
pytz	2011g
setuptools	0.6c11
SilverCity	0.9.7
SQLite	3.7.7.1
jQuery	1.4.2
Enabled Plugins:

TracMarkdownMacro	0.11.1	/var/tmp/trac-test/plugins/TracMarkdownMacro-0.11.1-py2.7.egg
TracMercurial	0.12.0.28dev-r10784	/var/tmp/trac-test/plugins/TracMercurial-0.12.0.28dev_r10784-py2.7.egg

Attachments

Change History

09/07/11 13:56:17 changed by peerst

Tried to find more info about this type of error on the web:

Apparently it is no longer possible to recompile regexps with flags in Python > 2.5

References found on this:

01/10/12 15:18:32 changed by ringare

I had the same problem using Python 2.6 and managed to fix the macro by a small modification to markdown/0.11/Markdown/macro.py. Change row 27-30 (for markdown macro 0.11.1)

LINK = compile(                                                                                                                          
    r'(\]\()([^) ]+)([^)]*\))|(<)([^>]+)(>)|(\n\[[^]]+\]: *)([^ \n]+)(.*\n)'                                                             
)                                                                                                                                        
HREF = compile(r'href=[\'"]?([^\'" ]*)')            

This seem to fix the problem!

into

LINK = r'(\]\()([^) ]+)([^)]*\))|(<)([^>]+)(>)|(\n\[[^]]+\]: *)([^ \n]+)(.*\n)'                                                           
HREF = r'href=[\'"]?([^\'" ]*)'                                                                                                          

(follow-up: ↓ 5 ) 07/14/12 16:57:19 changed by peerst

This ticked is used by spammers, I'm deleting my account now moved on to ChiliProject anyway since trac seems to be dead.

Ciao

(follow-up: ↓ 5 ) 10/01/12 23:18:02 changed by rjollos

  • status changed from new to closed.
  • resolution set to fixed.

(In [12085]) Fixes #9157, #10278: (0.11.2)

  • FIX: Allowed syntax for compiling a regular expression has changed by Python 2.6. Thanks to ringare and sdegrande for the patch.
  • Misc minor refactoring.
  • Updated documentation by copying the wiki page into README.

(in reply to: ↑ 4 ) 10/01/12 23:21:13 changed by anonymous

  • cc set to hasienda.

Replying to peerst:

This ticked is used by spammers, I'm deleting my account now moved on to ChiliProject anyway since trac seems to be dead.

The spam gets cleaned up daily, but we can and hope to do more in the future to prevent it (SiteUpgradeProposal).

No, Trac is not dead; we won't let them happen ;) Well, good luck to you for now, and hope to see you back here again eventually. ChiliProject looks nice as well.

10/01/12 23:29:46 changed by rjollos

(In [12086]) Refs #9157, #10278: Updated documentation now that macro is hosted in t-h.o.


Add/Change #9157 (ValueError: Cannot process flags argument with a compiled pattern (when displaying markdown))




Change Properties
Action