module file length limitations on windows?

Lonnie Princehouse finite.automaton at gmail.com
Thu Dec 16 12:46:37 EST 2004


I've run into some eccentric behavior...  It appears that one of my
modules is being cut off at exactly 2^14 characters when I try to
import it.  Has anyone else encountered this?  I can't find any mention
of such a bug, and stranger yet, other modules that exceed 16384
characters seem to work just fine.

In particular, suppose that my module foo.py contains the following as
its last line:

thing = "goodbye world"

Now, suppose that the length of the file is 16383 characters.  It works
just fine:

Python 2.4 (#60, Nov 30 2004, 11:49:19) [MSC v.1310 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import foo
>>>

But if I make the string longer, it explodes:

thing = "goodbye world spam spam spam spam spam"

Python 2.4 (#60, Nov 30 2004, 11:49:19) [MSC v.1310 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import foo
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "foo.py", line 583
thing = "goodbye world sp
^
SyntaxError: EOL while scanning single-quoted string


What in the world is going on here?!

This happens with Python 2.4 and 2.3.4 on win2k (under vmware), but it
does _not_ happen with 2.3.4 on Linux.   Very strange!  Could vmware be
the problem?

I have also tried replacing my unix newlines with DOS \r\n with the
exact same result.

I don't want to spend much time on this, since the workaround of
splitting the code into smaller files works just fine, but wow.. weird.




More information about the Python-list mailing list