From owner-freebsd-ports-bugs@FreeBSD.ORG Mon Oct 22 02:30:04 2007 Return-Path: Delivered-To: freebsd-ports-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2EC8E16A41B for ; Mon, 22 Oct 2007 02:30:04 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 1571313C4C3 for ; Mon, 22 Oct 2007 02:30:04 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.1/8.14.1) with ESMTP id l9M2U3aC051136 for ; Mon, 22 Oct 2007 02:30:03 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.1/8.14.1/Submit) id l9M2U3wE051127; Mon, 22 Oct 2007 02:30:03 GMT (envelope-from gnats) Resent-Date: Mon, 22 Oct 2007 02:30:03 GMT Resent-Message-Id: <200710220230.l9M2U3wE051127@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-ports-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Sunry Chen Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 08ABF16A417 for ; Mon, 22 Oct 2007 02:28:36 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id 013D313C4CC for ; Mon, 22 Oct 2007 02:28:36 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.1/8.14.1) with ESMTP id l9M2SCeb030350 for ; Mon, 22 Oct 2007 02:28:12 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.1/8.14.1/Submit) id l9M2SC36030349; Mon, 22 Oct 2007 02:28:12 GMT (envelope-from nobody) Message-Id: <200710220228.l9M2SC36030349@www.freebsd.org> Date: Mon, 22 Oct 2007 02:28:12 GMT From: Sunry Chen To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: ports/117388: chinese/pyDict has encode setting problem, and can't run in real console X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 22 Oct 2007 02:30:04 -0000 >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@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 from gtk import * File "/usr/local/lib/python2.5/site-packages/gtk-1.2/gtk.py", line 33, in _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 @@ -323,16 +323,17 @@ """Get the word this object describes.""" return self.word -from gtk import * -from GDK import * +prop = [" "," "," ","<<形容詞>>","<<副詞>>","art. ","<<連接詞>>","int. ","<<名詞>>"," "," ","num. ", "prep. "," ","pron. ","<<動詞>>","<<助動詞>>","<<非及物動詞>>","<<及物動詞>>","vbl. "," ","st. ", "pr. ","<<過去分詞>>","<<複數>>","ing. "," ","<<形容詞>>","<<副詞>>","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 = [" "," "," ","<<形容詞>>","<<副詞>>","art. ","<<連接詞>>","int. ","<<名詞>>"," "," ","num. ", "prep. "," ","pron. ","<<動詞>>","<<助動詞>>","<<非及物動詞>>","<<及物動詞>>","vbl. "," ","st. ", "pr. ","<<過去分詞>>","<<複數>>","ing. "," ","<<形容詞>>","<<副詞>>","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: