Show More
@@ -436,7 +436,14 b' static PyObject *posixfile(PyObject *sel' | |||||
436 | } |
|
436 | } | |
437 | else |
|
437 | else | |
438 | flags = _O_TEXT; |
|
438 | flags = _O_TEXT; | |
439 | if (plus) { |
|
439 | if (m0 == 'r' && !plus) { | |
|
440 | flags |= _O_RDONLY; | |||
|
441 | access = GENERIC_READ; | |||
|
442 | } else { | |||
|
443 | /* | |||
|
444 | work around http://support.microsoft.com/kb/899149 and | |||
|
445 | set _O_RDWR for 'w' and 'a', even if mode has no '+' | |||
|
446 | */ | |||
440 | flags |= _O_RDWR; |
|
447 | flags |= _O_RDWR; | |
441 | access = GENERIC_READ | GENERIC_WRITE; |
|
448 | access = GENERIC_READ | GENERIC_WRITE; | |
442 | fpmode[fppos++] = '+'; |
|
449 | fpmode[fppos++] = '+'; | |
@@ -446,25 +453,13 b' static PyObject *posixfile(PyObject *sel' | |||||
446 | switch (m0) { |
|
453 | switch (m0) { | |
447 | case 'r': |
|
454 | case 'r': | |
448 | creation = OPEN_EXISTING; |
|
455 | creation = OPEN_EXISTING; | |
449 | if (!plus) { |
|
|||
450 | flags |= _O_RDONLY; |
|
|||
451 | access = GENERIC_READ; |
|
|||
452 | } |
|
|||
453 | break; |
|
456 | break; | |
454 | case 'w': |
|
457 | case 'w': | |
455 | creation = CREATE_ALWAYS; |
|
458 | creation = CREATE_ALWAYS; | |
456 | if (!plus) { |
|
|||
457 | access = GENERIC_WRITE; |
|
|||
458 | flags |= _O_WRONLY; |
|
|||
459 | } |
|
|||
460 | break; |
|
459 | break; | |
461 | case 'a': |
|
460 | case 'a': | |
462 | creation = OPEN_ALWAYS; |
|
461 | creation = OPEN_ALWAYS; | |
463 | flags |= _O_APPEND; |
|
462 | flags |= _O_APPEND; | |
464 | if (!plus) { |
|
|||
465 | flags |= _O_WRONLY; |
|
|||
466 | access = GENERIC_WRITE; |
|
|||
467 | } |
|
|||
468 | break; |
|
463 | break; | |
469 | default: |
|
464 | default: | |
470 | PyErr_Format(PyExc_ValueError, |
|
465 | PyErr_Format(PyExc_ValueError, |
General Comments 0
You need to be logged in to leave comments.
Login now