[Python-bugs-list] [Bug #133592] Can't execute script from a DOS partition without .py ext

noreply@sourceforge.net noreply@sourceforge.net
Thu, 22 Feb 2001 23:01:50 -0800


Bug #133592, was updated on 2001-Feb-22 05:32
Here is a current snapshot of the bug.

Project: Python
Category: Python Interpreter Core
Status: Open
Resolution: None
Bug Group: Platform-specific
Priority: 5
Submitted by: montanaro
Assigned to : nobody
Summary: Can't execute script from a DOS partition without .py ext

Details: I have a Python script without a .py extension on a DOS partition
that runs fine using python 1.6 and 2.0, but fails with a syntax error on
2.1.  If I copy it back to a Linux ext2fs partition or give it a .py
extension it works fine.  Diff thinks DOS and extfs versions are identical
as does cksum.

    % python cgi-bin/query   
      File "cgi-bin/query", line 88
        print "serverdir could not be loaded"
        ^
    SyntaxError: invalid syntax

(Note that there are only 87 lines in the file.)

    % python cgi-bin/query.py
    Content-type: text/plain

    ...

I placed a copy of the script at

    http://www.musi-cal.com/~skip/query

Copying it from the DOS partition to the remote system using scp
complained:

    query : ERROR..continuing to end of file anyway

This, coupled with the erroneous line number leads me to suspect the syntax
error has to do with the presence of the DOS EOF marker.



Follow-Ups:

Date: 2001-Feb-22 23:01
By: tim_one

Comment:
Is this unique to this script, or does it happen for any old Python script?
 If the latter, can you come up with a minimal failing example?  If not,
there's scant reason to believe this is a Python bug.

If scp complains when you copy it, doesn't that suggest this specific file
is damaged in some way?

The DOS EOF marker is Ctrl-Z (Python chr(26)).

I observed one bizarre thing about the file I downloaded from your URL:

>>> f = open("query.txt", "rb")
>>> guts = f.read()
>>> list(guts).count(chr(0))
87
>>>

That is, it had 87 embedded null bytes, all at the end:

>>> guts[-87:] == chr(0) * 87
1
>>>

Beats me what that does!  It's not a legitimate text file, by C rules.  But
then who knows whether I successfully downloaded what you posted ...

wc query.txt
    87     231    2273 query.txt

Is that what you get?  I can't imagine why scp would care about null bytes,
though.

Face it, Skip:  your box is *hosed* <0.7 wink>.
-------------------------------------------------------

For detailed info, follow this link:
http://sourceforge.net/bugs/?func=detailbug&bug_id=133592&group_id=5470