Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
imputil.py, is this a bug ?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Stef Mientki  
View profile  
 More options Nov 7, 8:33 am
Newsgroups: comp.lang.python
From: Stef Mientki <stef.mien...@gmail.com>
Date: Fri, 06 Nov 2009 22:33:37 +0100
Local: Sat, Nov 7 2009 8:33 am
Subject: imputil.py, is this a bug ?
hello,

I get an error compiling with pyjamas, in the standard module imputil,
_import_top_module

Traceback (most recent call last):
  File
"D:\Data_Python_25\PyLab_Works\pylab_works_programs\PyJamas_Test\Vraag_Test 1.py",
line 22, in <module>
    from Vragenlijsten import Get_Vragenlijst
  File "P:\Python\Lib\site-packages\pyjd\imputil.py", line 109, in
_import_hook
    top_module = self._import_top_module(parts[0])
  File "P:\Python\Lib\site-packages\pyjd\imputil.py", line 217, in
_import_top_module
    module = item.import_top(name)
AttributeError: 'unicode' object has no attribute 'import_top'

It seems that elements of sys.path can be of the type unicode

    def _import_top_module(self, name):
        # scan sys.path looking for a location in the filesystem that
contains
        # the module, or an Importer object that can import the module.
        for item in sys.path:
            if isinstance(item, _StringType):
                module = self.fs_imp.import_from_dir(item, name)
            else:
                module = item.import_top(name)
            if module:
                return module
        return None

so by adding the next 2 lines, everything works ok.
            elif isinstance ( item, basestring ) :
                module = self.fs_imp.import_from_dir ( str(item), name)

is this a bug ?
(I'm using Python 2.5.2 on Windows )

thanks,
Stef Mientki


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Gabriel Genellina  
View profile  
 More options Nov 7, 1:20 pm
Newsgroups: comp.lang.python
From: "Gabriel Genellina" <gagsl-...@yahoo.com.ar>
Date: Fri, 06 Nov 2009 23:20:01 -0300
Local: Sat, Nov 7 2009 1:20 pm
Subject: Re: imputil.py, is this a bug ?
En Fri, 06 Nov 2009 18:33:37 -0300, Stef Mientki <stef.mien...@gmail.com>  
escribió:

> I get an error compiling with pyjamas, in the standard module imputil,  
> _import_top_module

Note that imputil is undocumented in 2.5, deprecated in 2.6 and  
definitively gone in 3.0

Yes, seems to be a bug. But given the current status of imputil, it's not  
likely to be fixed; certainly not in 2.5 which only gets security fixes  
now.

I cannot test it at this moment, but I'd use the unicode item directly  
(that is, self.fs_imp.import_from_dir(item, name)). Or perhaps  
item.encode(sys.getdefaultfilesystemencoding()). str(item) definitively  
won't work with directory names containing non-ascii characters.

Why are you using imputil in the first place?

--
Gabriel Genellina


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Stef Mientki  
View profile  
 More options Nov 7, 8:55 pm
Newsgroups: comp.lang.python
From: Stef Mientki <stef.mien...@gmail.com>
Date: Sat, 07 Nov 2009 10:55:31 +0100
Local: Sat, Nov 7 2009 8:55 pm
Subject: Re: imputil.py, is this a bug ?

thanks Gabriel,
well PyJamas is using (a copy) of it and I bumped into problems using
PyJamas.
I'll send this message to the PyJamas developers,
because this stuff is far beyond my knowledge.

cheers,
Stef


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
lkcl  
View profile  
 More options Nov 7, 10:29 pm
Newsgroups: comp.lang.python
From: lkcl <luke.leigh...@googlemail.com>
Date: Sat, 7 Nov 2009 03:29:24 -0800 (PST)
Local: Sat, Nov 7 2009 10:29 pm
Subject: Re: imputil.py, is this a bug ?
On Nov 7, 2:20 am, "Gabriel Genellina" <gagsl-...@yahoo.com.ar> wrote:

> Yes, seems to be a bug. But given the current status of imputil, it's not
> likely to be fixed; certainly not in 2.5 which only gets security fixes
> now.

 well, that bug's not the only one.  the other one that i found, which
i have been specifically ordered not to report (that or _any_ python
bugs, of which there have been several discovered in the past eight
months), will have to wait until the python developers rescind that
order.

if the python community is lucky, by the time that decision is made, i
will not have forgotten what those bugs are.

> (that is, self.fs_imp.import_from_dir(item, name)). Or perhaps
> item.encode(sys.getdefaultfilesystemencoding()). str(item) definitively
> won't work with directory names containing non-ascii characters.

> Why are you using imputil in the first place?

 it's an absolutely necessary and integral part of pyjamas-desktop
"platform overrides".

 it's absolutely essential to track, in exactly the same manner in
which python "normally" performs importing, and to give the platform-
specific "overrides" a chance to get in there, first.

 so, it is absolutely essential to have a correct working version of
imputil.py - and due to the bugs present, and the unwillingness of the
python team to fix those bugs, pyjamas-desktop is forced to maintain a
copy of imputil.py

 the "platform" is set to e.g. hulahop, pywebkitgtk or mshtml,
depending on the decision made by the user or the developer to use a
particular browser engine.  the platform name is stored in
pyjd.platform in exactly the same way that the system name is stored
in sys.platform.

 the way that the platform-specific overrides works is to perform AST
translation of the module, and then to look for the exact same module
but in platform/{modulename}{platformname}.py and perform AST
translation of _that_ module as well.

 then, at the top level, any global functions in the platform-specific
AST tree *replace* those in the "main" AST.  likewise, a node-walk
along all methods in all classes of the platform-specific AST tree.

 in this way, god-awful messy code like this:

 Widget.py
 class Widget:
     def do_something(self):
        if platform == 'mshtml':
            # do something terrible and ugly
        elif platform == 'pywebkitgtk':
            # do something only marginally better
        else:
            # do the default W3C standards-compliant thing

     def a_standard_function(self):
        # do something normal that all the browser engines get right

 can be replaced by three files, each of which encodes *only* the
logic associated with the god-awful ugliness of each browser:

 Widget.py
 class Widget:
     def do_something(self):
        # do the default W3C standards-compliant thing

     def a_standard_function(self):
        # do something normal that all the browser engines get right

 platform/Widgetpywebkitgtk.py
 class Widget:
     def do_something(self):
        # do something only marginally better

 platform/Widgetmshtml.py
 class Widget:
     def do_something(self):
       # do something terrible and ugly

 a similar trick could in fact be deployed to drastically simplify the
layout of e.g. distutils, _espeeecially_ the compiler and linker
modules, by using sys.platform as the "override", or, given that
that's not entirely the whole decision-making process, as i noted when
doing the mingw32 port of python, it would be better to set something
like distutils.platform and to use that.

 however, although the technique could be used in the distutils/
ccompiler.py case, the level of complexity of the code (the size of
each "override"), and the small number of actual modules, means that
there isn't actually that much benefit in deploying this AST-
overriding technique.

 in the pyjamas API, however, with over 75 user-interface modules, and
over 1200 functions, any one of which could be over-ridden by _eight_
separate platforms, each with their own quirks that can usually be
handled with one or two lines of code, the AST-merging idea that james
tauber came up with is an absolute god-send.

l.


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Terry Reedy  
View profile  
 More options Nov 8, 8:00 am
Newsgroups: comp.lang.python
From: Terry Reedy <tjre...@udel.edu>
Date: Sat, 07 Nov 2009 16:00:20 -0500
Local: Sun, Nov 8 2009 8:00 am
Subject: Re: imputil.py, is this a bug ?

Stef Mientki wrote:
> Gabriel Genellina wrote:
>> En Fri, 06 Nov 2009 18:33:37 -0300, Stef Mientki
>> <stef.mien...@gmail.com> escribió:

>>> I get an error compiling with pyjamas, in the standard module
>>> imputil, _import_top_module

>> Note that imputil is undocumented in 2.5, deprecated in 2.6 and
>> definitively gone in 3.0

It was deprecated because it is buggy and unmaintainable.

In 3.1 it has been replaced with the new written-in-Python importlib.
That has also been added to the upcoming 2.7.

Anyone using imputil and having problems with it should try the 2.7
version of importlib and see if it runs well-enough on earlier versions.

Terry Jan Reedy


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Terry Reedy  
View profile  
 More options Nov 8, 8:13 am
Newsgroups: comp.lang.python
From: Terry Reedy <tjre...@udel.edu>
Date: Sat, 07 Nov 2009 16:13:46 -0500
Local: Sun, Nov 8 2009 8:13 am
Subject: Re: imputil.py, is this a bug ?

lkcl wrote:
> On Nov 7, 2:20 am, "Gabriel Genellina" <gagsl-...@yahoo.com.ar> wrote:
>> Yes, seems to be a bug. But given the current status of imputil, it's not
>> likely to be fixed; certainly not in 2.5 which only gets security fixes
>> now.

>  well, that bug's not the only one.  the other one that i found, which
> i have been specifically ordered not to report

Imputil has been deprecated and has in 3.1 and will-be in 2.7 replaced
by importlib, written in Python. So reporting more bugs in imputil is
rather useless noise. So either use your patched version or try shifting
to the 2.7 importlib and see if it runs well enough on earlier versions.

 >(that or _any_ python bugs, of which there have been several
discovered in the past eight

> months), will have to wait until the python developers rescind that
> order.

Without seeing documentary proof, I am dubious that you have been
ordered to not properly report bugs in supported, not deprecated,
modules. If really so, post reports here and interested parties can try
to verify and possibly report them themselves. I, for instance, would be
interested in 3.1 bugs that do not require outside resources to verify.

Terry Jan Reedy


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google