Modify

Opened 6 years ago

Closed 5 years ago

Last modified 5 years ago

#9157 closed defect (fixed)

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

Reported by: peerst Owned by: Douglas Clifton
Priority: normal Component: MarkdownMacro
Severity: normal Keywords:
Cc: Steffen Hoffmann 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 (0)

Change History (6)

comment:1 Changed 6 years ago 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:

comment:2 Changed 5 years ago by Joakim Persson

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=[\'"]?([^\'" ]*)'                                                                                                          

comment:4 Changed 5 years ago 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

comment:4 Changed 5 years ago by Ryan J Ollos

Resolution: fixed
Status: newclosed

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

comment:5 in reply to:  4 Changed 5 years ago by anonymous

Cc: Steffen Hoffmann added; anonymous removed

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.

comment:6 Changed 5 years ago by Ryan J Ollos

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

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Douglas Clifton.
The resolution will be deleted.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.