Commits

Vinay Sajip committed fd5d6a3

Closes Issue #9: Fixed argument parsing bug reported by Sam Partington.

Comments (0)

Files changed (5)

CLILauncher/CLILauncher.rc

 //
 
 VS_VERSION_INFO VERSIONINFO
- FILEVERSION 1,0,0,2
- PRODUCTVERSION 1,0,0,2
+ FILEVERSION 1,0,0,3
+ PRODUCTVERSION 1,0,0,3
  FILEFLAGSMASK 0x17L
 #ifdef _DEBUG
  FILEFLAGS 0x1L
             VALUE "Comments", "Python Launcher for Windows"
             VALUE "CompanyName", "Python Software Foundation"
             VALUE "FileDescription", "Python Launcher for Windows (Console)"
-            VALUE "FileVersion", "1, 0, 0, 2"
+            VALUE "FileVersion", "1, 0, 0, 3"
             VALUE "InternalName", "py"
             VALUE "LegalCopyright", "Copyright (C) 2011 Python Software Foundation"
             VALUE "OriginalFilename", "py"
             VALUE "ProductName", "Python Launcher for Windows"
-            VALUE "ProductVersion", "1, 0, 0, 2"
+            VALUE "ProductVersion", "1, 0, 0, 3"
         END
     END
     BLOCK "VarFileInfo"

CLILauncher/launcher.c

         /* No file with shebang, or an unrecognised shebang.
          * Is the first arg a special version qualifier?
          */
-        valid = (*p == '-') && validate_version(&p[1]);
+        valid = (*p == L'-') && validate_version(&p[1]);
         if (valid) {
             ip = locate_python(&p[1]);
             if (ip == NULL)
                 fputws(L"\
 -X.Y-32: Launch the specified 32bit Python version", stdout);
             }
-            fputws(L"\n\nThe following help text is from Python:\n", stdout);
+            fputws(L"\n\nThe following help text is from Python:\n\n", stdout);
             fflush(stdout);
         }
     }

GUILauncher/GUILauncher.rc

 //
 
 VS_VERSION_INFO VERSIONINFO
- FILEVERSION 1,0,0,2
- PRODUCTVERSION 1,0,0,2
+ FILEVERSION 1,0,0,3
+ PRODUCTVERSION 1,0,0,3
  FILEFLAGSMASK 0x17L
 #ifdef _DEBUG
  FILEFLAGS 0x1L
             VALUE "Comments", "Python Launcher for Windows"
             VALUE "CompanyName", "Python Software Foundation"
             VALUE "FileDescription", "Python Launcher for Windows (GUI)"
-            VALUE "FileVersion", "1, 0, 0, 2"
+            VALUE "FileVersion", "1, 0, 0, 3"
             VALUE "InternalName", "GUILaunpyw"
             VALUE "LegalCopyright", "Copyright (C) 2011 Python Software Foundation"
             VALUE "OriginalFilename", "pyw"
             VALUE "ProductName", "Python Launcher for Windows"
-            VALUE "ProductVersion", "1, 0, 0, 2"
+            VALUE "ProductVersion", "1, 0, 0, 3"
         END
     END
     BLOCK "VarFileInfo"
 import os
 import sys
 
-VERSION = 'Version=1.0.0.2'
+VERSION = 'Version=1.0.0.3'
 MANUFACTURER = 'Manufacturer=Vinay Sajip'
 X86 = 'Platform=x86'
 X64 = 'Platform=x64'
         self.assertTrue(stdout.startswith(b'Python Launcher for Windows'))
         self.assertIn(b'The following help text is from Python:\r\n\r\nusage: ', stdout)
 
+    def test_version_specifier(self):
+        """Test that files named like a version specifier do not get 
+        misinterpreted as a version specifier when it does not have a shebang."""
+        for nohyphen in ['t3', 'x2.6', '_3.1-32']:
+            with open(nohyphen, 'w') as f:
+                f.write('import sys\nprint(sys.version)\nprint(sys.argv)')
+            try:
+                script = self.make_script(shebang_line='')
+                p =  subprocess.Popen([LAUNCHER, nohyphen, script], 
+                        stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+                stdout, stderr = p.communicate()
+                self.assertTrue(self.matches(stdout, DEFAULT_PYTHON2))
+            finally:
+                os.remove(nohyphen)
+ 
     # Tests with ASCII Python sources
     def test_shebang_ascii(self):
         "Test shebangs in ASCII files"