8000 Update codecs and test_codecs from cpython v3.12.4 by Andrewb12505 · Pull Request #5372 · RustPython/RustPython · GitHub
[go: up one dir, main page]

Skip to content

Update codecs and test_codecs from cpython v3.12.4 #5372

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions Lib/codecs.py
6728
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,9 @@ def __enter__(self):
def __exit__(self, type, value, tb):
self.stream.close()

def __reduce_ex__(self, proto):
raise TypeError("can't serialize %s" % self.__class__.__name__)

###

class StreamReader(Codec):
Expand Down Expand Up @@ -663,6 +666,9 @@ def __enter__(self):
def __exit__(self, type, value, tb):
self.stream.close()

def __reduce_ex__(self, proto):
raise TypeError("can't serialize %s" % self.__class__.__name__)

###

class StreamReaderWriter:
Expand Down Expand Up @@ -750,6 +756,9 @@ def __enter__(self):
def __exit__(self, type, value, tb):
self.stream.close()

def __reduce_ex__(self, proto):
raise TypeError("can't serialize %s" % self.__class__.__name__)

###

class StreamRecoder:
Expand Down Expand Up @@ -866,6 +875,9 @@ def __enter__(self):
def __exit__(self, type, value, tb):
self.stream.close()

def __reduce_ex__(self, proto):
raise TypeError("can't serialize %s" % self.__class__.__name__)

### Shortcuts

def open(filename, mode='r', encoding=None, errors='strict', buffering=-1):
Expand All @@ -878,7 +890,8 @@ def open(filename, mode='r', encoding=None, errors='strict', buffering=-1):
codecs. Output is also codec dependent and will usually be
Unicode as well.

Underlying encoded files are always opened in binary mode.
If encoding is not None, then the
underlying encoded files are always opened in binary mode.
The default file mode is 'r', meaning to open the file in read mode.

encoding specifies the encoding which is to be used for the
Expand Down Expand Up @@ -1114,13 +1127,3 @@ def make_encoding_map(decoding_map):
_false = 0
if _false:
import encodings

### Tests

if __name__ == '__main__':

# Make stdout translate Latin-1 output into UTF-8 output
sys.stdout = EncodedFile(sys.stdout, 'latin-1', 'utf-8')

# Have stdin translate Latin-1 input into UTF-8 input
sys.stdin = EncodedFile(sys.stdin, 'utf-8', 'latin-1')
Loading
Loading
0