mirror of
https://github.com/python/cpython.git
synced 2025-08-22 17:55:18 +00:00
gh-133036: Deprecate codecs.open (#133038)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Co-authored-by: Victor Stinner <vstinner@python.org>
This commit is contained in:
parent
732d1b0241
commit
4e294f6feb
11 changed files with 58 additions and 37 deletions
|
@ -884,7 +884,6 @@ class StreamRecoder:
|
|||
### Shortcuts
|
||||
|
||||
def open(filename, mode='r', encoding=None, errors='strict', buffering=-1):
|
||||
|
||||
""" Open an encoded file using the given mode and return
|
||||
a wrapped version providing transparent encoding/decoding.
|
||||
|
||||
|
@ -912,8 +911,11 @@ def open(filename, mode='r', encoding=None, errors='strict', buffering=-1):
|
|||
.encoding which allows querying the used encoding. This
|
||||
attribute is only available if an encoding was specified as
|
||||
parameter.
|
||||
|
||||
"""
|
||||
import warnings
|
||||
warnings.warn("codecs.open() is deprecated. Use open() instead.",
|
||||
DeprecationWarning, stacklevel=2)
|
||||
|
||||
if encoding is not None and \
|
||||
'b' not in mode:
|
||||
# Force opening of the file in binary mode
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue