[ python-Bugs-1225059 ] Line endings problem with Python 2.4.1 cause imports to fail

SourceForge.net noreply at sourceforge.net
Tue Jun 21 20:56:22 CEST 2005


Bugs item #1225059, was opened at 2005-06-21 20:56
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1225059&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Parser/Compiler
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Nicolas Lehuen (nlehuen)
Assigned to: Nobody/Anonymous (nobody)
Summary: Line endings problem with Python 2.4.1 cause imports to fail

Initial Comment:
Hi, 

Here is my Python version string :

ActivePython 2.4.1 Build 245 (ActiveState Corp.) based on
Python 2.4.1 (#65, Mar 30 2005, 09:33:37) [MSC v.1310
32 bit (Intel)] on win32

I'm having troubles with a series of source code files
that were working perfectly under Python 2.4.0 and
earlier releases. I have enclosed one of those source
files which should be independent of the rest, so that
you can test it by yourself.

Now, here is my problem :

------------ Test 1 ---------------
C:\projets\development\python\tcc>python
ActivePython 2.4.1 Build 245 (ActiveState Corp.) based on
Python 2.4.1 (#65, Mar 30 2005, 09:33:37) [MSC v.1310
32 bit (Intel)] on win3
Type "help", "copyright", "credits" or "license" for
more information.
>>> import util
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "util.py", line 612
    _max=None
             ^
SyntaxError: invalid syntax

--- interpretation : this is the problem, the Python
interpreter fails to parse the file. Note that is is a
DOS-style file, with \r\n as lines separator, instead
of simply \n. If I convert the file to a UNIX-style, \n
separated lines format, then everything is OK.

------------ Test 2 ---------------
C:\projets\development\python\tcc>python -i util.py

C:\projets\development\python\tcc>python -i util.py
>>> ^Z

--- interpretation : launching the script instead of
importing it is OK. It seems that the way scripts are
loaded for direct launching is different than the way
they are loaded for import.

------------ Test 3 ---------------
C:\projets\development\python\tcc>python -m util
  File "C:\projets\development\python\tcc\util.py",
line 612
    _max=None
             ^
SyntaxError: invalid syntax

--- interpretation : using another way to import the
module and launch it yield the same buggy behaviour.
Once again, if I convert line termination from DOS to
UNIX, everything is OK.

I've seen a few bugs related to rstrip() and readline()
having a new behaviour, maybe this problem is related ?
This is quite an annoying bug, because some perfectly
valid code just stop working. The workaround is to
convert everything to UNIX format, which is a bit
tiresome given that my code is distributed on a bunch
of computers...

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

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


More information about the Python-bugs-list mailing list