473,404 Members | 2,195 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

module file length limitations on windows?

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.

Jul 18 '05 #1
4 1504
Lonnie Princehouse wrote:
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.

As a further data point, it doesn't appear to happen under Cygwin with
2.4 either:

sholden@dellboy ~
$ wc module.py
8177 2 8191 module.py

sholden@dellboy ~
$ python
Python 2.4 (#1, Dec 4 2004, 20:10:33)
[GCC 3.3.3 (cygwin special)] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
import module hello
sholden@dellboy ~
$ vi module.py

sholden@dellboy ~
$ wc module.py
8177 5 8206 module.py

sholden@dellboy ~
$ python
Python 2.4 (#1, Dec 4 2004, 20:10:33)
[GCC 3.3.3 (cygwin special)] on cygwin
Type "help", "copyright", "credits" or "license" for more information. import module

hello spam spam spam

Is it possible you've somehow inserted non-printing characters? Seems
bizarrely improbable to me that 2^14 would be a significant boundary to
the interpreter.

regards
Steve
--
Steve Holden http://www.holdenweb.com/
Python Web Programming http://pydish.holdenweb.com/
Holden Web LLC +1 703 861 4237 +1 800 494 3119
Jul 18 '05 #2
No non-printing characters.

However, I just tried copying the file (from a windows cmd prompt), and
the copy was cut off at the same point the interpreter is getting to.
When I edit the file with vim, though, the whole thing comes through.
I think this is a pretty strong indication that this monkey-business is
happening either in Windows or in vmware, and has nothing to do with
Python.

Confirmed. I rebooted the (virtual) machine and the problem is gone.
Weird.

Jul 18 '05 #3
[If there is a separate list for elementtree, please someone
clue me ... I didn't see one.]

Fredrik or other xml / elementtree gurus:

I see from the source that ElementTree.write() writes

<?xml version="1.0"? encoding=[whatever]>

at the beginning of the xml output if an encoding
other than utf-8 or us-ascii is selected. Shouldn't
it also write that if utf-8 or us-ascii is being
used? Or at least the

<?xml version="1.0"?>

?

Thanks,
Steve

Jul 18 '05 #4
Stephen Waterbury wrote:
[If there is a separate list for elementtree, please someone
clue me ... I didn't see one.]
the xml-sig is preferred, I think.
Fredrik or other xml / elementtree gurus:

I see from the source that ElementTree.write() writes

<?xml version="1.0"? encoding=[whatever]>

at the beginning of the xml output if an encoding
other than utf-8 or us-ascii is selected. Shouldn't
it also write that if utf-8 or us-ascii is being
used? Or at least the

<?xml version="1.0"?>


this is mostly for historical reasons; early versions only supported UTF-8 output,
and never generated encoding directives, so people ended up writing:

print >>myfile, "<document>"
for elem in list_of_elements:
ElementTree(elem).write(myfile)
print >>myfile, "</document>"

version 1.3 will probably include an option to always write the header.

(note that the XML header isn't needed for UTF-8 and ASCII; if it's not there,
a proper XML parser will treat the stream as UTF-8, and ASCII is a compatible
subset of UTF-8).

</F>

Jul 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Brandon Walters | last post by:
I wrote a file download module for my website. The reason for the file download module is that my website downloads work on a credit based system. So I need to keep track of and limit daily...
11
by: john_ramsden | last post by:
I have to prepare an Apache/PHP based (or perl if easier) web page that allows a user to upload very large files, possibly over 10 Gbytes and maybe up to 100 Gbytes. I'm aware that file upload...
1
by: Peter Åstrand | last post by:
There's a new PEP available: PEP 324: popen5 - New POSIX process module A copy is included below. Comments are appreciated. ---- PEP: 324 Title: popen5 - New POSIX process module
10
by: sam | last post by:
Hi group, I m wondering which Excel module is good to be used by Python? Thanks Sam
2
by: praba kar | last post by:
Dear All, I have one doubt. Is there python.ini file like php.ini in Php? Actually php.ini file controls many aspects of PHP's behavior. The following details of php.ini will explain about...
3
by: Debbie Carter | last post by:
Can XML files be easily encrypted?
21
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Uploading files from a local computer to a remote web server has many useful purposes, the most...
13
by: Daniel Fetchinson | last post by:
Was looking at PEP 3108, http://www.python.org/dev/peps/pep-3108/ , Is it just me or others also think that it would be a major loss to remove tkinter from the python core? PEP 3108 starts off...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.