mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
- Issue #2091: error correctly on open() with mode 'U' and '+'
open() accepted a 'U' mode string containing '+', but 'U' can only be used with 'r'. Patch from Jeff Balogh and John O'Connor.
This commit is contained in:
parent
882667203c
commit
c94a1dc4c9
4 changed files with 14 additions and 11 deletions
|
@ -181,8 +181,8 @@ def open(file, mode="r", buffering=-1, encoding=None, errors=None,
|
|||
text = "t" in modes
|
||||
binary = "b" in modes
|
||||
if "U" in modes:
|
||||
if creating or writing or appending:
|
||||
raise ValueError("can't use U and writing mode at once")
|
||||
if creating or writing or appending or updating:
|
||||
raise ValueError("mode U cannot be combined with 'x', 'w', 'a', or '+'")
|
||||
import warnings
|
||||
warnings.warn("'U' mode is deprecated",
|
||||
DeprecationWarning, 2)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue