The equery command uses local.getpreferredenoidng() to get the current using locale, but this function returns x-mac-simp-chinese on my Mac. $ python Python 2.6.5 (release26-maint, Oct 24 2010, 16:35:47) [GCC 4.2.1 (Gentoo 4.2.1_p5664, Apple Inc. build 5664)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import locale >>> locale.getpreferredencoding() 'x-mac-simp-chinese' Reproducible: Always Steps to Reproduce: 1.install gentoo prefix on Mac 2.run "equery which equery" Actual Results: When run equery, this error message appears: $ equery w gentoolkit Traceback (most recent call last): File "/Users/yegle/Gentoo/usr/bin/equery", line 38, in <module> equery.main() File "/Users/yegle/Gentoo/usr/lib/python2.6/site-packages/gentoolkit/equery/__init__.py", line 349, in main loaded_module.main(module_args) File "/Users/yegle/Gentoo/usr/lib/python2.6/site-packages/gentoolkit/equery/which.py", line 99, in main pp.uprint(os.path.normpath(ebuild_path)) File "/Users/yegle/Gentoo/usr/lib/python2.6/site-packages/gentoolkit/pprinter.py", line 180, in uprint sep = sep.encode(encoding, 'replace') LookupError: unknown encoding: x-mac-simp-chinese $ emerge --info Portage 2.2.01.17168-prefix (prefix/darwin/macos/10.6/x86, gcc-4.2.1, unavailable, 10.5.0 i386) ================================================================= System uname: Darwin-10.5.0-i386-32bit Timestamp of tree: Sun, 28 Nov 2010 05:42:21 +0000 distcc 3.1-toolwhip.1 i386-apple-darwin10.0 [disabled] app-shells/bash: 4.1_p7 dev-lang/python: 2.6.5-r2 sys-devel/autoconf: 2.68 sys-devel/automake: 1.11.1 sys-devel/gcc-config: 1.4.1-r00.2 sys-devel/libtool: 2.4 sys-devel/make: 3.82 Repositories: gentoo_prefix ACCEPT_KEYWORDS="* ~x86-macos" ACCEPT_LICENSE="* -@EULA" CBUILD="i686-apple-darwin10" CFLAGS="-O2 -pipe -march=prescott -fomit-frame-pointer" CHOST="i686-apple-darwin10" CONFIG_PROTECT="/etc" CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/portage /etc/revdep-rebuild /etc/terminfo" CXXFLAGS="-O2 -pipe -march=prescott -fomit-frame-pointer" DISTDIR="/Users/yegle/Gentoo/usr/portage/distfiles" FEATURES="assume-digests binpkg-logs collision-protect distlocks fixlafiles fixpackages news nostrip parallel-fetch preserve-libs protect-owned sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch" GENTOO_MIRRORS="http://distfiles.gentoo.org" LANG="zh_CN.UTF-8" LDFLAGS="-Wl,-dead_strip_dylibs" MAKEOPTS="-j3" PKGDIR="/Users/yegle/Gentoo/usr/portage/packages" PORTAGE_CONFIGROOT="/Users/yegle/Gentoo/" PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages" PORTAGE_TMPDIR="/Users/yegle/Gentoo/var/tmp" PORTDIR="/Users/yegle/Gentoo/usr/portage" PORTDIR_OVERLAY="" SYNC="rsync://rsync.prefix.freens.org/gentoo-portage-prefix" USE="aqua coreaudio cracklib cxx mmx mmxext modules ncurses objc objc++ prefix readline sse sse2 ssl vim-syntax x86-macos zlib" APACHE2_MODULES="actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" ELIBC="Darwin" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ubx" INPUT_DEVICES="keyboard mouse" KERNEL="Darwin" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" PHP_TARGETS="php5-2" RUBY_TARGETS="ruby18" USERLAND="GNU" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account" Unset: CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, FFLAGS, INSTALL_MASK, LC_ALL, LINGUAS, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS
This really looks like a python issue when complied on the Mac prefix environment. Python 2.6.5 (release26-maint, Nov 22 2010, 14:20:01) [GCC 4.2.1 (Gentoo 4.2.1_p5664, Apple Inc. build 5664)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import locale >>> import codecs >>> codecs.lookup(locale.getpreferredencoding()) <codecs.CodecInfo object for encoding mac-roman at 0x4225e0> >>> codecs.lookup('x-mac-simp-chinese') Traceback (most recent call last): File "<stdin>", line 1, in <module> LookupError: unknown encoding: x-mac-simp-chinese
Older python ebuilds used to remove the /usr/lib/python2.6/encodings/ directory when USE=build was enabled. You might check whether that directory exists and contains a healthy set of encodings.
The docs say locale.getpreferredencoding() "only returns a guess": http://docs.python.org/library/locale.html#locale.getpreferredencoding So, maybe it's valid for the returned encoding to trigger a LookupError? If so, it would make sense for the caller to check for this case and fall back to a reliable encoding like utf_8 or ascii if necessary.
This commit should fix the issue with equery. http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=2b5cf6a3b096ab728212a210075bd1f4d173dac0
This was released in gentoolkit-0.3.0