ports/117388: chinese/pyDict has encode setting problem, and can't run in real console
Sunry Chen
sunrychen at gmail.com
Mon Oct 22 02:30:04 UTC 2007
>Number: 117388
>Category: ports
>Synopsis: chinese/pyDict has encode setting problem, and can't run in real console
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-ports-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Mon Oct 22 02:30:03 UTC 2007
>Closed-Date:
>Last-Modified:
>Originator: Sunry Chen
>Release: FreeBSD 6.2-STABLE
>Organization:
Shenzhen Institute of Technology
>Environment:
FreeBSD www.525183.com 6.2-STABLE FreeBSD 6.2-STABLE #8: Tue Sep 18 23:01:05 CST
2007 hplc at www.525183.com:/usr/obj/usr/src/sys/MYKERNEL i386
>Description:
Run pydict in console or in X window's xterm, it generates such error:
File "/usr/local/bin/pydict", line 332
SyntaxError: Non-ASCII character '\xa7' in file /usr/local/bin/pydict on line 33
2, but no encoding declared; see http://www.python.org/peps/pep-0263.html for de
tails
This is caused by source encoding problem. After solving this problem, it runs ok in X, but in real console it says:
Traceback (most recent call last):
File "/usr/local/bin/pydict", line 326, in <module>
from gtk import *
File "/usr/local/lib/python2.5/site-packages/gtk-1.2/gtk.py", line 33, in <mod
ule>
_gtk.gtk_init()
RuntimeError: cannot open display
This is because in real console there's no DISPLAY, while the code in line 326 or some others want to initialize the DISPLAY.
>How-To-Repeat:
Fresh installed chinese/pyDict, run pydict in console, not in X window's term!
>Fix:
1. Add source encoding big5 for pydict source.
2. Adjust pydict python source code, add a judge statement not to import gtk or any other source which affecting running it in real console mode.
Patch attached with submission follows:
--- pydict.orig 2007-10-22 10:03:06.000000000 +0800
+++ pydict 2007-10-22 10:09:37.000000000 +0800
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-# -*- encoding: big5 -*-
+# -*- coding: big5 -*-
#-------------------------------------------------
# this is a program that utilize the library of xdict.
# Made by Daniel Gau <r90057 at im.ntu.edu.tw>
@@ -323,16 +323,17 @@
"""Get the word this object describes."""
return self.word
-from gtk import *
-from GDK import *
+prop = [" "," "," ","<<§Î®eµü>>","<<°Æµü>>","art. ","<<³s±µµü>>","int. ","<<¦Wµü>>"," "," ","num. ", "prep. "," ","pron. ","<<°Êµü>>","<<§U°Êµü>>","<<«D¤Îª«°Êµü>>","<<¤Îª«°Êµü>>","vbl. "," ","st. ", "pr. ","<<¹L¥h¤Àµü>>","<<½Æ¼Æ>>","ing. "," ","<<§Î®eµü>>","<<°Æµü>>","pla. ","pn. "," "]
+
from string import split,replace,strip,lstrip,find,lower
-import GtkExtra
import sys,os,string
+if os.environ.has_key('DISPLAY') and len(sys.argv) == 1:
+ from gtk import *
+ from GDK import *
+ import GtkExtra
-prop = [" "," "," ","<<§Î®eµü>>","<<°Æµü>>","art. ","<<³s±µµü>>","int. ","<<¦Wµü>>"," "," ","num. ", "prep. "," ","pron. ","<<°Êµü>>","<<§U°Êµü>>","<<«D¤Îª«°Êµü>>","<<¤Îª«°Êµü>>","vbl. "," ","st. ", "pr. ","<<¹L¥h¤Àµü>>","<<½Æ¼Æ>>","ing. "," ","<<§Î®eµü>>","<<°Æµü>>","pla. ","pn. "," "]
-
-class Pref(GtkDialog):
+ class Pref(GtkDialog):
def __init__(self,modal=TRUE,app=None):
GtkDialog.__init__(self)
self.connect("destroy", self.quit)
@@ -483,7 +484,7 @@
def quit(self,w=None,event=None):
self.hide()
-class HelpDialog(GtkDialog):
+ class HelpDialog(GtkDialog):
def __init__(self,modal=TRUE,file=None):
GtkDialog.__init__(self)
self.set_title("pyDict Help")
@@ -543,7 +544,7 @@
self.quit()
-class App(GtkWindow):
+ class App(GtkWindow):
def __init__(self):
GtkWindow.__init__(self,WINDOW_TOPLEVEL)
self.create_vars()
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-ports-bugs
mailing list