Edgewall Software
Modify

Opened 15 years ago

Closed 15 years ago

#7955 closed defect (worksforme)

LookupError: unknown encoding: utf8_euro

Reported by: udono Owned by:
Priority: normal Milestone:
Component: general Version: 0.12dev
Severity: normal Keywords:
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description (last modified by Emmanuel Blot)

0.12multirepos-r7684 The following Error raises on "Timeline" and other menu items:

2009-01-09 18:17:13,383 Trac[main] ERROR: unknown encoding: utf8_euro
Traceback (most recent call last):
  File "/usr/lib/python2.5/site-packages/Trac-0.12multirepos_r7684-py2.5.egg/tra
c/web/main.py", line 456, in _dispatch_request
    dispatcher.dispatch(req)
  File "/usr/lib/python2.5/site-packages/Trac-0.12multirepos_r7684-py2.5.egg/tra
c/web/main.py", line 213, in dispatch
    resp = chosen_handler.process_request(req)
  File "/usr/lib/python2.5/site-packages/Trac-0.12multirepos_r7684-py2.5.egg/tra
c/timeline/web_ui.py", line 126, in process_request
    'today': format_date(today),
  File "/usr/lib/python2.5/site-packages/Trac-0.12multirepos_r7684-py2.5.egg/trac/util/datefmt.py", line 121, in format_date
    return format_datetime(t, format, tzinfo=tzinfo)
  File "/usr/lib/python2.5/site-packages/Trac-0.12multirepos_r7684-py2.5.egg/trac/util/datefmt.py", line 113, in format_datetime
    return unicode(text, encoding, 'replace')
LookupError: unknown encoding: utf8_euro
My system locale:
LANG=de_DE.utf8@euro
LC_CTYPE="de_DE.utf8@euro"
LC_NUMERIC="de_DE.utf8@euro"
LC_TIME="de_DE.utf8@euro"
LC_COLLATE=C
LC_MONETARY="de_DE.utf8@euro"
LC_MESSAGES="de_DE.utf8@euro"
LC_PAPER="de_DE.utf8@euro"
LC_NAME="de_DE.utf8@euro"
LC_ADDRESS="de_DE.utf8@euro"
LC_TELEPHONE="de_DE.utf8@euro"
LC_MEASUREMENT="de_DE.utf8@euro"
LC_IDENTIFICATION="de_DE.utf8@euro"
LC_ALL=

Attachments (0)

Change History (4)

comment:1 by udono, 15 years ago

The following patch helps in my case:

diff -u /usr/lib/python2.5/site-packages/Trac-0.12multirepos_r7684-py2.5.egg/trac/util/datefmt.py.orig /usr/lib/python2.5/site-packages/Trac-0.12multirepos_r7684-py2.5.egg/trac/util/datefmt.py—- /usr/lib/python2.5/site-packages/Trac-0.12multirepos_r7684-py2.5.egg/trac/util/datefmt.py.orig 2009-01-09 21:44:04.000000000 +0100 +++ /usr/lib/python2.5/site-packages/Trac-0.12multirepos_r7684-py2.5.egg/trac/util/datefmt.py 2009-01-09 21:35:47.000000000 +0100 @@ -32,11 +32,11 @@

def to_datetime(t, tzinfo=None):

"""Convert t into a datetime object, using the following rules:

+

  • If t is already a datetime object, it is simply returned.
  • If t is None, the current time will be used.
  • If t is a number, it is interpreted as a timestamp.

+

If no tzinfo is given, the local timezone will be used.

Any other input will trigger a TypeError.

@@ -90,12 +90,12 @@

r = int(round(r)) return '%d %s' % (r, r == 1 and unit or unit_plural)

return

+

def format_datetime(t=None, format='%x %X', tzinfo=None):

"""Format the datetime object t into an unicode string

If t is None, the current time will be used.

+

The formatting will be done using the given format, which consist of conventional strftime keys. In addition the format can be 'iso8601' to specify the international date format.

@@ -110,6 +110,10 @@

if sys.platform != 'win32' or sys.version_info[:2] > (2, 3):

encoding = locale.getlocale(locale.LC_TIME)[1] or encoding # Python 2.3 on windows doesn't know about 'XYZ' alias for 'cpXYZ'

+ try: + (encoding, False) = encoding.split("_") + except: + pass

return unicode(text, encoding, 'replace')

def format_date(t=None, format='%x', tzinfo=None):

@@ -211,7 +215,7 @@

if dt is None:

dt = _parse_relative_time(text, tzinfo)

if dt is None:

  • hint = get_date_format_hint()

+ hint = get_date_format_hint()

raise TracError('"%s" is an invalid date, or the date format '

'is not known. Try "%s" instead.' % (text, hint), 'Invalid Date')

@@ -415,7 +419,7 @@

_gmt_index = bisect(_pytz_zones, 'GMT') all_timezones = _pytz_zones[:_gmt_index] + all_timezones[1:] + \

_pytz_zones[_gmt_index:]

+

except ImportError:

def timezone(tzname):

comment:2 by Emmanuel Blot, 15 years ago

Description: modified (diff)
Milestone: 0.12
Severity: blockernormal

Please use verbatim blocks ({{{ }}}) and always preview your ticket before submitting it: your message is hardly readable.

Is your locale properly configured on your machine?

utf8@euro is quite unusual: utf8 (unicode) already defined the euro symbol. It's quite common to use @euro for ISO-8859 page code, but it looks like unusual with UTF-8.

This is not a blocker issue anyway: simply use another locale (de_DE.utf8 should do it)

in reply to:  1 comment:3 by anonymous, 15 years ago

Sorry, wrong formatted… again:

diff -u /usr/lib/python2.5/site-packages/Trac-0.12multirepos_r7684-py2.5.egg/trac/util/datefmt.py.orig  /usr/lib/python2.5/site-packages/Trac-0.12multirepos_r7684-py2.5.egg/trac/util/datefmt.py--- /usr/lib/python2.5/site-packages/Trac-0.12multirepos_r7684-py2.5.egg/trac/util/datefmt.py.orig	2009-01-09 21:44:04.000000000 +0100
+++ /usr/lib/python2.5/site-packages/Trac-0.12multirepos_r7684-py2.5.egg/trac/util/datefmt.py	2009-01-09 21:35:47.000000000 +0100
@@ -32,11 +32,11 @@
 
 def to_datetime(t, tzinfo=None):
     """Convert `t` into a `datetime` object, using the following rules:
-    
+
      - If `t` is already a `datetime` object, it is simply returned.
      - If `t` is None, the current time will be used.
      - If `t` is a number, it is interpreted as a timestamp.
-     
+
     If no `tzinfo` is given, the local timezone will be used.
 
     Any other input will trigger a `TypeError`.
@@ -90,12 +90,12 @@
             r = int(round(r))
             return '%d %s' % (r, r == 1 and unit or unit_plural)
     return ''
-    
+
 def format_datetime(t=None, format='%x %X', tzinfo=None):
     """Format the `datetime` object `t` into an `unicode` string
 
     If `t` is None, the current time will be used.
-    
+
     The formatting will be done using the given `format`, which consist
     of conventional `strftime` keys. In addition the format can be 'iso8601'
     to specify the international date format.
@@ -110,6 +110,10 @@
     if sys.platform != 'win32' or sys.version_info[:2] > (2, 3):
         encoding = locale.getlocale(locale.LC_TIME)[1] or encoding
         # Python 2.3 on windows doesn't know about 'XYZ' alias for 'cpXYZ'
+    try:
+        (encoding, False) = encoding.split("_")
+    except:
+        pass
     return unicode(text, encoding, 'replace')
 
 def format_date(t=None, format='%x', tzinfo=None):
@@ -211,7 +215,7 @@
     if dt is None:
         dt = _parse_relative_time(text, tzinfo)
     if dt is None:
-        hint = get_date_format_hint()        
+        hint = get_date_format_hint()
         raise TracError('"%s" is an invalid date, or the date format '
                         'is not known. Try "%s" instead.' % (text, hint),
                         'Invalid Date')
@@ -415,7 +419,7 @@
     _gmt_index = bisect(_pytz_zones, 'GMT')
     all_timezones = _pytz_zones[:_gmt_index] + all_timezones[1:] + \
                     _pytz_zones[_gmt_index:]
- 
+
 except ImportError:
 
     def timezone(tzname):

comment:4 by Christian Boos, 15 years ago

Keywords: multirepos removed
Resolution: worksforme
Status: newclosed

See PythonBug:3011. Upgrade to Python 2.6.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The ticket will remain with no owner.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from (none) to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.