Commits

Amaury Forgeot d'Arc committed 3e2de48

#3626: On cygwin, starting "python z" would not display any error message:

printf("%ls") fails if the wide string is 1 char long :-(

Comments (0)

Files changed (2)

 Core and Builtins
 -----------------
 
+- Issue #3626: On cygwin, starting python with a non-existent script name
+  would not display anything if the file name is only 1 character long.
+
 - Issue #4176: Fixed a crash when pickling an object which ``__reduce__``
   method does not return iterators for the 4th and 5th items.
 
-- Issue 3723: Fixed initialization of subinterpreters.
+- Issue #3723: Fixed initialization of subinterpreters.
 
 - Issue #4213: The file system encoding is now normalized by the
   codec subsystem, for example UTF-8 is turned into utf-8.
 
 		if (sts==-1 && filename!=NULL) {
 			if ((fp = _wfopen(filename, L"r")) == NULL) {
-				fprintf(stderr, "%ls: can't open file '%ls': [Errno %d] %s\n",
-					argv[0], filename, errno, strerror(errno));
+				char cfilename[PATH_MAX];
+				size_t r = wcstombs(cfilename, filename, PATH_MAX);
+				if (r == PATH_MAX)
+					/* cfilename is not null-terminated;
+					 * forcefully null-terminating it
+					 * might break the shift state */
+					strcpy(cfilename, "<file name too long>");
+				if (r == ((size_t)-1))
+					strcpy(cfilename, "<unprintable file name>");
+				fprintf(stderr, "%ls: can't open file '%s': [Errno %d] %s\n",
+					argv[0], cfilename, errno, strerror(errno));
 
 				return 2;
 			}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.