Modify

Opened 5 years ago

Closed 5 years ago

#13730 closed defect (fixed)

Error with Trac 1.4

Reported by: Oleg Vassin <oleg.vassin@…> Owned by: ttressieres
Priority: normal Component: IncludeSourcePartialPlugin
Severity: major Keywords:
Cc: Trac Release: 1.4

Description

On web page:

Error: Macro IncludeSource(...) failed
'Environment' object has no attribute 'get_repository'
and/or
'Stream' object has no attribute 'generate'

In log:

2020-01-10 11:17:56,858 Trac[formatter] ERROR: Macro IncludeSource(trunk/externals.txt, mimetype=application/x-shellscript) failed for <Resource u'wiki:WikiStart'>:
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/trac/wiki/formatter.py", line 818, in _macro_formatter
    return macro.ensure_inline(macro.process(args), in_paragraph)
  File "/usr/local/lib/python2.7/site-packages/trac/wiki/formatter.py", line 389, in process
    text = self.processor(text)
  File "/usr/local/lib/python2.7/site-packages/trac/wiki/formatter.py", line 361, in _macro_processor
    text)
  File "build/bdist.freebsd-12.1-RELEASE-p1-amd64/egg/includesource/IncludeSource.py", line 110, in expand_macro
    repos = self.env.get_repository(reponame)
AttributeError: 'Environment' object has no attribute 'get_repository'

PS: May be used deprecated interface?

Attachments (2)

includesource.patch (4.2 KB) - added by ttressieres@… 5 years ago.
patch to port this macro to Trac 1.4
support_trac_1.4.patch (4.8 KB) - added by ttressieres 5 years ago.
new patch for 1.4.x without error when start or end parameter are not present

Download all attachments as: .zip

Change History (15)

comment:1 Changed 5 years ago by Ryan J Ollos

Owner: changed from Chris Heller to Ryan J Ollos
Status: newaccepted

Changed 5 years ago by ttressieres@…

Attachment: includesource.patch added

patch to port this macro to Trac 1.4

comment:2 Changed 5 years ago by ttressieres@…

With the patch in attachment I'm able to use this macro on Trac 1.4.1

comment:3 Changed 5 years ago by ttressieres

Owner: changed from Ryan J Ollos to ttressieres

comment:4 Changed 5 years ago by oleg.vassin@…

I tried this patch, but anyway the error:

'Stream' object has no attribute 'generate'

comment:5 Changed 5 years ago by anonymous

2020-02-28 07:58:49,551 Trac[formatter] ERROR: Macro IncludeSource(trunk/externals.txt, mimetype=application/x-shellscript) failed for <Resource u'wiki:WikiStart'>:
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/trac/wiki/formatter.py", line 818, in _macro_formatter
    return macro.ensure_inline(macro.process(args), in_paragraph)
  File "/usr/local/lib/python2.7/site-packages/trac/wiki/formatter.py", line 389, in process
    text = self.processor(text)
  File "/usr/local/lib/python2.7/site-packages/trac/wiki/formatter.py", line 361, in _macro_processor
    text)
  File "build/bdist.freebsd-12.1-RELEASE-p1-amd64/egg/includesource/IncludeSource.py", line 204, in expand_macro
    | Transformer(xpath3).replace(header)
AttributeError: 'Stream' object has no attribute 'generate'

comment:6 Changed 5 years ago by ttressieres

Are you sure the patch was applied correctly ? There is no more call to generate() function in the code

comment:7 in reply to:  6 Changed 5 years ago by anonymous

Replying to ttressieres:

Are you sure the patch was applied correctly ?

I apologize! Did not remove the previous * .egg

There is no more call to generate() function in the code

But still get error:

Error: Macro IncludeSource(trunk/externals.txt, mimetype=application/x-shellscript) failed
unsupported operand type(s) for -: 'NoneType' and 'int'
2020-03-04 15:35:41,897 Trac[formatter] ERROR: Macro IncludeSource(trunk/externals.txt, mimetype=application/x-shellscript) failed for <Resource u'wiki:WikiStart'>:
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/trac/wiki/formatter.py", line 818, in _macro_formatter
    return macro.ensure_inline(macro.process(args), in_paragraph)
  File "/usr/local/lib/python2.7/site-packages/trac/wiki/formatter.py", line 389, in process
    text = self.processor(text)
  File "/usr/local/lib/python2.7/site-packages/trac/wiki/formatter.py", line 361, in _macro_processor
    text)
  File "build/bdist.freebsd-12.1-RELEASE-p2-amd64/egg/includesource/IncludeSource.py", line 184, in expand_macro
    src = mv.render(formatter.context, mimetype, src, file_name, url, annotations)
  File "/usr/local/lib/python2.7/site-packages/trac/mimeview/api.py", line 821, in render
    return self._render_source(context, result, annotations)
  File "/usr/local/lib/python2.7/site-packages/trac/mimeview/api.py", line 847, in _render_source
    data = (annotator, annotator.get_annotation_data(context))
  File "/usr/local/lib/python2.7/site-packages/trac/mimeview/api.py", line 1064, in get_annotation_data
    'offset': context.get_hint('lineno', 1) - 1
TypeError: unsupported operand type(s) for -: 'NoneType' and 'int'

comment:8 Changed 5 years ago by oleg.vassin@…

This error occurs only if there are no parameters for linenum.

Error:

[[IncludeSource(trunk/externals.txt, mimetype=application/x-shellscript)]]

Success if set start=1 :

[[IncludeSource(trunk/externals.txt, start=1, mimetype=application/x-shellscript)]]

Changed 5 years ago by ttressieres

Attachment: support_trac_1.4.patch added

new patch for 1.4.x without error when start or end parameter are not present

comment:9 Changed 5 years ago by ttressieres

OK I reproduced this error, see the new patch file

comment:10 in reply to:  9 Changed 5 years ago by anonymous

Replying to ttressieres:

OK I reproduced this error, see the new patch file

Thanks a lot! Everything works great.

comment:11 Changed 5 years ago by Ryan J Ollos

Owner: changed from ttressieres to Ryan J Ollos

Will review and commit patch.

comment:12 Changed 5 years ago by Ryan J Ollos

Owner: changed from Ryan J Ollos to ttressieres
Status: acceptedassigned

comment:13 Changed 5 years ago by ttressieres

Resolution: fixed
Status: assignedclosed

In 17684:

apply patch to adapt plugin to Trac 1.4 (fix #13730)

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain ttressieres.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


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

 
Note: See TracTickets for help on using tickets.