This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
| Author | amaury.forgeotdarc |
|---|---|
| Recipients | amaury.forgeotdarc, christian.heimes, gvanrossum |
| Date | 2007年11月12日.13:09:45 |
| SpamBayes Score | 0.08415637 |
| Marked as misclassified | No |
| Message-id | <1194872986.3.0.777072862993.issue1415@psf.upfronthosting.co.za> |
| In-reply-to |
| Content | |
|---|---|
I made some checks with the vc2005 (msvcr80) runtime library:
- fd==-2 corresponds to the _NO_CONSOLE_FILENO constant.
A comment in the CRT code says:
/*
* For stdin, stdout & stderr, we use _NO_CONSOLE_FILENO (a value
* different from _INVALID_HANDLE_VALUE to distinguish between
* a failure in opening a file & a program run without a console.
*/
- in this case, stderr is a buffered FILE*, but the flush() method
always fails. This makes not difference for python2.5, because it never
looks at the return value of fprintf (which is not very consistent, BTW).
Since pythonw (2.5) silently discards any output to stderr, we could
achieve the same by opening the nul file...
--- c:/temp/t 2007年11月12日 13:54:34.105463200 +0100
+++ c:/afa/python/py3k/Modules/_fileio.c 2007年11月12日 13:52:42.576675100 +0100
@@ -149,6 +149,15 @@
if (PyArg_ParseTupleAndKeywords(args, kwds, "i|si:fileio",
kwlist, &fd, &mode, &closefd)) {
+#ifdef MS_WINDOWS
+ /* Windows sets the descriptor to _NO_CONSOLE_FILENO when */
+ /* the program is run without a console */
+ if (fd == -2)
+ {
+ fd = open("nul", "r+");
+ }
+ else
+#endif
if (fd < 0) {
PyErr_SetString(PyExc_ValueError,
"Negative filedescriptor"); |
|
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2007年11月12日 13:09:46 | amaury.forgeotdarc | set | spambayes_score: 0.0841564 -> 0.08415637 recipients: + amaury.forgeotdarc, gvanrossum, christian.heimes |
| 2007年11月12日 13:09:46 | amaury.forgeotdarc | set | spambayes_score: 0.0841564 -> 0.0841564 messageid: <1194872986.3.0.777072862993.issue1415@psf.upfronthosting.co.za> |
| 2007年11月12日 13:09:46 | amaury.forgeotdarc | link | issue1415 messages |
| 2007年11月12日 13:09:45 | amaury.forgeotdarc | create | |