This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Line endings problem with Python 2.4.1 cause imports to fail
Type: Stage:
Components: Interpreter Core Versions: Python 2.4
process
Status: closed Resolution: duplicate
Dependencies: Superseder:
Assigned To: doerwalter Nosy List: doerwalter, nlehuen
Priority: normal Keywords:

Created on 2005-06-21 18:56 by nlehuen, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
util.py nlehuen, 2005-06-21 18:56 Test source file
Messages (5)
msg25605 - (view) Author: Nicolas Lehuen (nlehuen) Date: 2005-06-21 18:56
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...
msg25606 - (view) Author: Walter Dörwald (doerwalter) * (Python committer) Date: 2005-06-22 10:56
Logged In: YES 
user_id=89016

This is indead a duplicate of bug #1175396 and related ones.
Your problem should be fixed in the current CVS version. Can
you retry with the current CVS version? As a possible
workaround you might want to change the encoding from
cp-1252 to iso-8859-1. Does this fix anything for you?
msg25607 - (view) Author: Nicolas Lehuen (nlehuen) Date: 2005-06-22 12:14
Logged In: YES 
user_id=61056

I have not enough time to test the CVS version right now,
but if I change the encoding header from :

# -*- coding: CP1252 -*-

to :

# -*- coding: iso-8859-1 -*-

then everything is OK. So I guess this is really a duplicate
of others bugs related to the CP1252 encoder ?

Thanks for your reply !
msg25608 - (view) Author: Nicolas Lehuen (nlehuen) Date: 2005-06-22 12:22
Logged In: YES 
user_id=61056

Turns out testing the CVS version was not so lengthy... So
yes, this is fixed in the current CVS version !

Regards,
Nicolas
msg25609 - (view) Author: Walter Dörwald (doerwalter) * (Python committer) Date: 2005-06-22 12:22
Logged In: YES 
user_id=89016

Closing the report. Thanks for the quick followup.
History
Date User Action Args
2022-04-11 14:56:11adminsetgithub: 42106
2005-06-21 18:56:22nlehuencreate