encoding(X-MAC-KOREAN) problem on Python 2.5

2008.12.23 12:13 | Posted by bar4mi
It occurred when I installed Trac on my macbook. 

bash-3.2# trac-admin ./Trac/mkb initenv
Traceback (most recent call last):
  File "/opt/local/bin/trac-admin", line 8, in <module>
    load_entry_point('Trac==0.11.2.1', 'console_scripts', 'trac-admin')()
  File "/opt/local/lib/python2.5/site-packages/trac/admin/console.py", line 1294, in run
    return admin.onecmd(command)
  File "/opt/local/lib/python2.5/site-packages/trac/admin/console.py", line 120, in onecmd
    line = to_unicode(line, encoding)
  File "/opt/local/lib/python2.5/site-packages/trac/util/text.py", line 59, in to_unicode
    return unicode(text, charset, 'replace')
LookupError: unknown encoding: X-MAC-KOREAN

According to python's issue(1276), it was fixed but my Python version(2.5) including MacPorts is not fixed. 

Python team offer the temporary patch which works great on my macbook.

It can just be inserted to 508th lines of aliases.py(/opt/local/lib/python2.5/encodings/aliases.py).

# temporary mac CJK aliases for 3.0, will be replaced in 3.1
    'x_mac_japanese'      : 'shift_jis',
    'x_mac_korean'        : 'euc_kr',
    'x_mac_simp_chinese'  : 'gb2312',
    'x_mac_trad_chinese'  : 'big5',

신고

티스토리 툴바