Python 2.6 issues

3 views
Skip to first unread message

JKP

unread,
Nov 3, 2008, 8:29:21 AM11/3/08
to PyInstaller
Hi there

I've found a couple of issues using PyInstaller with Python 2.6, one
trivial, one not-so. I need some help getting the second resolved.

Firstly, BaseException.message is depreciated, therefore you need to
replace the code in ZipOwner with this:

<code>
class ZipOwner(Owner):
def __init__(self, path):
try:
self.__zip = zipimport.zipimporter(path)
except zipimport.ZipImportError, e:
raise OwnerError('%s: %s' % (str(e), path))
Owner.__init__(self, path)
</code>

Second, and far more serious is that usage of encodings is broken
using PyInstaller under 2.6. The problem seems to be due to the fact
that in the new code they have changed the way that encodings are
imported:

In the encoding module's search_function implementation they have
changed the import statement to specifically use absolute imports,
which causes the PyImporter code to fail:

<code>
# Import is absolute to prevent the possibly malicious
import of a
# module with side-effects that is not in the 'encodings'
package.
mod = __import__('encodings.' + modname,
fromlist=_import_tail, level=0)
</code>

To test this just compile a script with the following contents:

<code>
import codecs
codecs.locate( "utf-8" )
</code>

I don't know your importer code at all, so for now I've had to just do
a cheesy hack in your importHook code:

<code>
def importHook(self, name, globals=None, locals=None,
fromlist=None, level=-1):

# first see if we could be importing a relative name
#print "importHook(%s, %s, locals, %s)" % (name,
getattr(globals, '__name__', None), fromlist)
_sys_modules_get = sys.modules.get
_self_doimport = self.doimport
threaded = self.threaded

# break the name being imported up so we get:
# a.b.c -> [a, b, c]
nmparts = namesplit(name)

if len(nmparts) and nmparts[0] == "encodings":
level = -1
</code>

This appears to be the only real issue running under 2.6 though which
is the good news so if this can get fixed up then we should be good to
go.

Thanks in advance.

Jamie
Reply all
Reply to author
Forward
0 new messages