[Python-bugs-list] [ python-Bugs-561326 ] ihooks.FancyModuleLoader fails
noreply@sourceforge.net
noreply@sourceforge.net
Tue, 28 May 2002 04:01:12 -0700
Bugs item #561326, was opened at 2002-05-28 04:05
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=561326&group_id=5470
Category: Python Library
Group: None
>Status: Closed
Resolution: None
Priority: 5
Submitted By: Mark Hammond (mhammond)
Assigned to: Jack Jansen (jackjansen)
Summary: ihooks.FancyModuleLoader fails
Initial Comment:
ihooks.FancyModuleLoader() fails to load .py files on
Windows. It yields a syntax error.
The root of the problem is that FancyModuleLoader()
uses imp.get_suffixes() to determine what mode to use
with a specific file extension. Since the Universal
Newline support, .py files are specified as "rb"
(whereas previously they were "r").
FancyModuleImporter then opens the file using "rb", and
the "\r\n" line endings cause a syntax error.
To reproduce, simply execute Lib/rexec.py. This will
create an interactive prompt in a restricted
environment. Attempt to import *any* module implemented
in a .py file not already loaded (eg, base64). The
import fails with a SyntaxError
Assigning to Jack in the hope the correct fix is
obvious ;) Assign back if you like!
----------------------------------------------------------------------
>Comment By: Jack Jansen (jackjansen)
Date: 2002-05-28 13:01
Message:
Logged In: YES
user_id=45365
Turns out the mode flag in filedescr entries is not only passed to fopen() but also returned to Python scripts (through the imp interface), but in Python code we need "U" as the mode. Fixed in import.c rev. 2.202 by putting "U" in the filedescr table, and fixing it before passing it to fopen().
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=561326&group_id=5470