Looking for a scripting language

John Machin sjmachin at lexicon.net
Tue May 7 09:45:11 EDT 2002


Peter Hansen <peter at engcorp.com> wrote in message news:<3CD717CA.4E204E31 at engcorp.com>...
> deckerben wrote:
> > 
> > D:\D\SCRIPTS\PROGRAM\Python\PyXML-0.7.1>python setup.py build
> > Traceback (most recent call last):
> >   File "D:\USER\DJGPP\lib\python2.0\distutils\util.py", line 135, in
> > check_envir on
> >     os.environ['PLAT'] = get_platform()
> >   File "D:\USER\DJGPP\lib\python2.0\distutils\util.py", line 43, in
> > get_platform
> > 
> >     (osname, host, release, version, machine) = os.uname()
> > TypeError: unpack non-sequence
> 
> That last line suggests that your implementation of os.uname()
> is not returning what was expected (a sequence consisting of 
> those five specific items.  I'm not qualified to advise you in 
> this :-), but I would recommend checking into the os module
> to see if the compiler/OS support for whatever that routine
> does is non-standard or something.  Or make a fake version
> which returns those five items with reasonable guesses:
> 
> def fake_uname():
>     return 'BenDos', 'localhost', '2.4', 'yadda', 'Pentium'
> 
> import os
> os.uname = fake_uname
> 
> Or something kludgy like that... it might let you work
> past the problem anyway.
> 

Sorry: kludge, yes. Work past problem, no. Look at the caller:

def get_platform ():
    """Return a string that identifies the current platform.  This is
used
[snip]
    For non-POSIX platforms, currently just returns 'sys.platform'.
    """
    if os.name != "posix" or not hasattr(os, 'uname'):
        # XXX what about the architecture? NT is Intel or Alpha,
        # Mac OS is M68k or PPC, etc.
        return sys.platform

    # Try to distinguish various flavours of Unix

    (osname, host, release, version, machine) = os.uname()
[followed by heaps of code testing for specific values of osname, none
of them 'BenDos']

So ... this means that (1) you are pretending to be "posix" [can you
live up to that?] and (2) you are providing an os.uname [which is
optional; for instance, the win32 platform doesn't provide one] ...
the call to sys.platform is skipped and then you go splat because as
the exception message says, your os.uname is not returning a sequence.

Not having done a port, I'm not qualified either, but until a better
suggestion comes along: (1) kill off your malformed os.uname (2)
ensure that your sys.platform returns something sensible, maybe
"djgpp" (3) Hope that distutils does something sensible with unknown
values returned from sys.platform; you may need to submit some patches
to the distutils maintainers. You may need to "register" your port
with (a) the distutils maintainers (b) the BDFL. You may need to ask
generally what other known gotchas there might be for a porter ...



More information about the Python-list mailing list