[Python-bugs-list] [ python-Bugs-233592 ] Can't execute script from a DOS partition without .py ext

nobody nobody@sourceforge.net
Tue, 27 Feb 2001 07:59:09 -0800


Artifact #233592, was updated on 2001-02-22 05:32
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=233592&group_id=5470

Category: Python Interpreter Core
Group: Platform-specific
Status: Closed
Priority: 5
Submitted By: Skip Montanaro
Assigned to: Nobody/Anonymous
Summary: Can't execute script from a DOS partition without .py ext

Initial Comment:
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.



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

Comment By: Skip Montanaro
Date: 2001-02-27 07:59

Message:
Logged In: YES 
user_id=44345

agreed - it's almost certainly something fishy on my system


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

Comment By: Tim Peters
Date: 2001-02-22 23:01

Message:
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>.

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

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