From owner-freebsd-ports-bugs@FreeBSD.ORG Tue Nov 6 13:10:02 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 8B78016A418 for ; Tue, 6 Nov 2007 13:10:02 +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 6226613C4BA for ; Tue, 6 Nov 2007 13:10:02 +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 lA6DA0da035466 for ; Tue, 6 Nov 2007 13:10:00 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.1/8.14.1/Submit) id lA6DA0oC035465; Tue, 6 Nov 2007 13:10:00 GMT (envelope-from gnats) Resent-Date: Tue, 6 Nov 2007 13:10:00 GMT Resent-Message-Id: <200711061310.lA6DA0oC035465@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 0CD7516A420 for ; Tue, 6 Nov 2007 13:00:17 +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 E635A13C48D for ; Tue, 6 Nov 2007 13:00:16 +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 lA6D03Ld081076 for ; Tue, 6 Nov 2007 13:00:03 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.1/8.14.1/Submit) id lA6D03le081074; Tue, 6 Nov 2007 13:00:03 GMT (envelope-from nobody) Message-Id: <200711061300.lA6D03le081074@www.freebsd.org> Date: Tue, 6 Nov 2007 13:00:03 GMT From: Sunry Chen To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: ports/117863: [patch]chinese/pyDict: Fix encode problem, adjust it can 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: Tue, 06 Nov 2007 13:10:02 -0000 >Number: 117863 >Category: ports >Synopsis: [patch]chinese/pyDict: Fix encode problem, adjust it can run in real console >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Tue Nov 06 13:10:00 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: As I mentioned in ports/117388, http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/117388(As I submitted this PR, the ports/117388 can be closed): 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 python source. 2. Adjust 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: diff -ruN pyDict.orig/Makefile pyDict/Makefile --- pyDict.orig/Makefile Tue Nov 6 18:26:52 2007 +++ pyDict/Makefile Tue Nov 6 19:57:58 2007 @@ -9,9 +9,12 @@ PORTVERSION= 0.2.6.3 PORTREVISION= 3 CATEGORIES= chinese -MASTER_SITES= ftp://freebsd.sinica.edu.tw/pub/statue/pyDict/ +MASTER_SITES= ftp://freebsd.sinica.edu.tw/pub/statue/pyDict/ \ + http://www.525183.com/freebsd/pyDict/ \ + http://www.chinatinco.com/freebsd/pyDict/ \ + http://525183.serverbox.org/freebsd/pyDict/ -MAINTAINER= ports@FreeBSD.org +MAINTAINER= sunrychen@gmail.com COMMENT= A Chinese <-> English dictionary, under both console and X11 RUN_DEPENDS= ${LOCALBASE}/include/pygtk/pygtk.h:${PORTSDIR}/x11-toolkits/py-gtk \ @@ -29,7 +32,7 @@ .include -do-patch: +pre-patch: ${REINPLACE_CMD} -e 's,/bin/grep,${GREP},g' \ -e 's,--after-context=20,-A 20,g' \ -e 's,/usr/X11R6,${PREFIX},g' ${WRKSRC}/dict.py diff -ruN pyDict.orig/files/patch-dict.py pyDict/files/patch-dict.py --- pyDict.orig/files/patch-dict.py Thu Jan 1 08:00:00 1970 +++ pyDict/files/patch-dict.py Tue Nov 6 18:28:54 2007 @@ -0,0 +1,50 @@ +--- ./dict.py.orig Wed Oct 17 22:02:16 2007 ++++ ./dict.py Tue Nov 6 18:28:47 2007 +@@ -1,4 +1,5 @@ + #!/usr/bin/env python ++# -*- coding: big5 -*- + #------------------------------------------------- + # this is a program that utilize the library of xdict. + # Made by Daniel Gau +@@ -322,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) +@@ -482,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") +@@ -542,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: