[Python-bugs-list] [ python-Bugs-772763 ] modulefinder bug in load_module()

SourceForge.net noreply@sourceforge.net
Fri, 18 Jul 2003 08:32:22 -0700


Bugs item #772763, was opened at 2003-07-16 21:20
Message generated for change (Comment added) made by atuining
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=772763&group_id=5470

Category: Python Library
Group: Python 2.2
Status: Open
Resolution: None
Priority: 5
Submitted By: Anthony Tuininga (atuining)
Assigned to: Just van Rossum (jvr)
Summary: modulefinder bug in load_module()

Initial Comment:
in revision 1.6 of file dist/src/Lib/modulefinder.py at
line 265 there is a line that reads

            co = compile(fp.read()+'\n', pathname, 'exec')

That line should read instead

           co = compile(fp.read().replace("\r\n", "\n")
+'\n', pathname, 'exec')

as otherwise files with Windows line endings do not
compile correctly on Unix platforms. The import
statement itself seems to handle this properly. Perhaps
this can also be done with the universal line endings
"U" option to the open command?


----------------------------------------------------------------------

>Comment By: Anthony Tuininga (atuining)
Date: 2003-07-18 09:32

Message:
Logged In: YES 
user_id=619560

I personally don't have any problem with you closing this
bug since it isn't a bug in Python 2.3. But then you might
want to modify the proposed patch by Thomas to indicate that
it only works in Python 2.3 and if you use it in Python 2.2,
the problem with DOS line endings on Unix will appear. For
those of us who care, we can make the one line change noted
above and bundle it with our tools. So go ahead and close.

----------------------------------------------------------------------

Comment By: Just van Rossum (jvr)
Date: 2003-07-18 09:26

Message:
Logged In: YES 
user_id=92689

I don't see how we can fix this for 2.2 without backporting 
universal newlines, so I'm very tempted to close this bug is "won't 
fix"...

----------------------------------------------------------------------

Comment By: Anthony Tuininga (atuining)
Date: 2003-07-18 07:37

Message:
Logged In: YES 
user_id=619560

If that is the case, there is still a bug for usage in 2.2.
Then you must make the changes as noted above or you will
run into problems with DOS line endings on a Unix platform.
Whether or not this must be fixed in the main library or
whether those of us who bundle the code need to make the
changes ourselves is up to those who manage Python. I am no
longer concerned since it does work with Python 2.3.

----------------------------------------------------------------------

Comment By: Thomas Heller (theller)
Date: 2003-07-18 00:43

Message:
Logged In: YES 
user_id=11105

FYI, I've filed patch 773179, which changes the
compatibility requirements for modulefinder to >= Python
2.2. I don't want py2exe to support older versions anymore.

----------------------------------------------------------------------

Comment By: Anthony Tuininga (atuining)
Date: 2003-07-17 16:24

Message:
Logged In: YES 
user_id=619560

As it turns out, import.c has already been modified to
handle universal line endings so this is not a bug for
Python 2.3. It is rather a bug for Python 2.2 and lower. So
I guess we should decide whether or not to remove the
requirement for Python 1.5 support sooner rather than later.
I can modify my own copy for Python 2.2 to handle this
situation properly.

----------------------------------------------------------------------

Comment By: Anthony Tuininga (atuining)
Date: 2003-07-17 11:09

Message:
Logged In: YES 
user_id=619560

It is already incompatible since the removal of apply() took
place a while back. I would not mind seeing the compat
request removed. It removes constraints from future development.

OTOH, the "U" stuff would have to be added to the imp module
when it opens the file. Thus, the modulefinder.py file
itself would not change.

----------------------------------------------------------------------

Comment By: Thomas Heller (theller)
Date: 2003-07-17 10:57

Message:
Logged In: YES 
user_id=11105

Per the comment at the top of the file, modulefinder should
be kept compatible with 1.5.2, so the "U" mode should be
used with care ;-)

OTOH, *I* requested the compatibility, and I no longer see a
need for it. Should the compat request be removed?

----------------------------------------------------------------------

Comment By: Just van Rossum (jvr)
Date: 2003-07-17 10:29

Message:
Logged In: YES 
user_id=92689

Ah, imp :-(.

2.3: they're baking the release candidate today, so yeah, it's too 
late :-(

----------------------------------------------------------------------

Comment By: Anthony Tuininga (atuining)
Date: 2003-07-17 10:27

Message:
Logged In: YES 
user_id=619560

The only problem is that the file is opened within the imp
module when the find_module() method. So this means changes
at the C level, right?

And its already too late for Python 2.3?? I thought it was
still two weeks away from release?

Perhaps the simple fix with the replace() code can be used
for now?

I am not sure about the release strategy so I might be way
off base here. :-)

----------------------------------------------------------------------

Comment By: Just van Rossum (jvr)
Date: 2003-07-17 10:22

Message:
Logged In: YES 
user_id=92689

This should be done with the "U" mode indeed. Can you provide a 
patch? It's too late for 2.3 anyway, so take your time...

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=772763&group_id=5470