Modify

Opened 7 years ago

Closed 2 years ago

#1688 closed defect (wontfix)

'charmap' codec can't encode character

Reported by: coenen.rob@… Owned by: coderanger
Priority: normal Component: CombineWikiPlugin
Severity: normal Keywords:
Cc: Trac Release: 0.10

Description

I am getting (Ubuntu Feisty) this error when trying to export to PDF HTML export works

Traceback (most recent call last):
  File "/var/lib/python-support/python2.5/trac/web/main.py", line 387, in dispatch_request
    dispatcher.dispatch(req)
  File "/var/lib/python-support/python2.5/trac/web/main.py", line 237, in dispatch
    resp = chosen_handler.process_request(req)
  File "/usr/lib/python2.5/site-packages/TracWebAdmin-0.1.2dev_r4429-py2.5.egg/webadmin/web_ui.py", line 109, in process_request
    path_info)
  File "build/bdist.linux-i686/egg/combinewiki/web_ui.py", line 58, in process_admin_request
    return formats[format]['provider'].process_combinewiki(req, format, title, rightpages)
  File "build/bdist.linux-i686/egg/combinewiki/formats.py", line 55, in process_combinewiki
    files = [self._page_to_file(req, p) for p in pages]
  File "build/bdist.linux-i686/egg/combinewiki/formats.py", line 106, in _page_to_file
    page = wiki_to_html(text, self.env, req).encode(codepage)
  File "encodings/iso8859_15.py", line 12, in encode
UnicodeEncodeError: 'charmap' codec can't encode character u'\u2019' in position 431: character maps to <undefined>

Attachments (1)

patch_1688.diff (1.3 KB) - added by ljcoomber 7 years ago.
Suggested workaround

Download all attachments as: .zip

Change History (4)

comment:1 Changed 7 years ago by coenen.rob@…

export to TiddlyWiki gives the error below. Export to .ps (Postscript) gives 0 byte files

Traceback (most recent call last):
  File "/var/lib/python-support/python2.5/trac/web/main.py", line 387, in dispatch_request
    dispatcher.dispatch(req)
  File "/var/lib/python-support/python2.5/trac/web/main.py", line 237, in dispatch
    resp = chosen_handler.process_request(req)
  File "/usr/lib/python2.5/site-packages/TracWebAdmin-0.1.2dev_r4429-py2.5.egg/webadmin/web_ui.py", line 109, in process_request
    path_info)
  File "build/bdist.linux-i686/egg/combinewiki/web_ui.py", line 58, in process_admin_request
    return formats[format]['provider'].process_combinewiki(req, format, title, rightpages)
  File "build/bdist.linux-i686/egg/combinewiki/formats.py", line 174, in process_combinewiki
    formatter.format(text, out)
  File "/var/lib/python-support/python2.5/trac/wiki/formatter.py", line 822, in format
    result = re.sub(self.wiki.rules, self.replace, line)
  File "re.py", line 142, in sub
    return _compile(pattern, 0).sub(repl, string, count)
  File "/var/lib/python-support/python2.5/trac/wiki/formatter.py", line 768, in replace
    replacement = self.handle_match(fullmatch)
  File "/var/lib/python-support/python2.5/trac/wiki/formatter.py", line 764, in handle_match
    return internal_handler(match, fullmatch)
  File "build/bdist.linux-i686/egg/combinewiki/formats.py", line 438, in _macro_formatter
    rv = system_message('Error: Macro %s(%s) failed' % (name, args),
NameError: global name 'system_message' is not defined

Changed 7 years ago by ljcoomber

Suggested workaround

comment:2 Changed 7 years ago by ljcoomber

I've added a workaround patch that allows an admin to set a default error handling strategy for the encoding, as per http://docs.python.org/lib/codec-base-classes.html

By default, the encoder will still use 'strict' handling and an error will be thrown if a Unicode encoded character is found. Within the 'combinewiki' section of the Trac config file, setting "encode-errors = replace" will replace invalid characters with a valid one (? on my system) so you still get a PDF. Note this setting will allow encoding to fail silently - if is more important that you don't have 'junk' characters in your PDF than to have the PDF itself, then fix the source pages.

This patch will also break the use of the 'combinewiki' section for specifying arguments to HTML DOC; they should go under 'combinewiki-pdf' if you want to use this patch unmodified.

Tested on Trac 0.10, Python 2.5.1

comment:3 Changed 2 years ago by rjollos

  • Resolution set to wontfix
  • Status changed from new to closed

Deprecated: Please try the TracWikiToPdfPlugin.

Add Comment

Modify Ticket

Action
as closed The owner will remain coderanger.
The resolution will be deleted. Next status will be 'reopened'.
Author


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

 
Note: See TracTickets for help on using tickets.