Skip to content

Instantly share code, notes, and snippets.

@JelleZijlstra
Created February 27, 2017 05:02
Show Gist options
  • Save JelleZijlstra/0aaeda5bb10cca3cf7fdc649ae2304ea to your computer and use it in GitHub Desktop.
Save JelleZijlstra/0aaeda5bb10cca3cf7fdc649ae2304ea to your computer and use it in GitHub Desktop.
diff of py2 and py3 codecs.pyi
$ diff stdlib/2/codecs.pyi stdlib/3/codecs.pyi
2c2
< # https://docs.python.org/2/library/codecs.html
---
> # https://docs.python.org/3/library/codecs.html
9d8
< Optional,
18c17
< # str is the raw form and unicode is the cooked form.
---
> # bytes is the raw form and str is the cooked form.
20,21c19,20
< # There *are* str->str and unicode->unicode encodings in the standard library.
< # And unlike python 3, they are in fairly widespread use.
---
> # There *are* bytes->bytes and str->str encodings in the standard library.
> # Python 3.5 supposedly might change something there.
23,24c22,23
< _decoded = unicode
< _encoded = str
---
> _decoded = str
> _encoded = bytes
44,51c43,50
< def __init__(self, encode: _encode_type, decode: _decode_type, streamreader: _stream_reader_type = ..., streamwriter: _stream_writer_type = ..., incrementalencoder: _incremental_encoder_type = ..., incrementaldecoder: _incremental_decoder_type = ..., name: str = ...) -> None: ...
< encode = ... # type: _encode_type
< decode = ... # type: _decode_type
< streamreader = ... # type: _stream_reader_type
< streamwriter = ... # type: _stream_writer_type
< incrementalencoder = ... # type: _incremental_encoder_type
< incrementaldecoder = ... # type: _incremental_decoder_type
< name = ... # type: str
---
> def __init__(self, encode: _encode_type, decode: _decode_type, streamreader: _stream_reader_type = ..., streamwriter: _stream_writer_type = ..., incrementalencoder: _incremental_encoder_type = ..., incrementaldecoder: _incremental_decoder_type = ..., name: str = ...) -> None:
> self.encode = encode
> self.decode = decode
> self.streamreader = streamreader
> self.streamwriter = streamwriter
> self.incrementalencoder = incrementalencoder
> self.incrementaldecoder = incrementaldecoder
> self.name = name
72c71
< def EncodedFile(file: BinaryIO, data_encoding: str, file_encoding: str = ..., errors: Optional[str] = ...) -> 'StreamRecoder':
---
> def EncodedFile(file: BinaryIO, data_encoding: str, file_encoding: str = ..., errors: str = ...) -> 'StreamRecoder':
119d117
< errors = ... # type: str
121c119
< ...
---
> self.errors = errors
134d131
< errors = ... # type: str
136c133
< ...
---
> self.errors = errors
149d145
< buffer = ... # type: str
151c147,148
< ...
---
> IncrementalEncoder.__init__(self, errors)
> self.buffer = ''
158d154
< buffer = ... # type: str
160c156,157
< ...
---
> IncrementalDecoder.__init__(self, errors)
> self.buffer = b''
170d166
< errors = ... # type: str
172c168
< ...
---
> self.errors = errors
181d176
< errors = ... # type: str
183c178
< ...
---
> self.errors = errors
196,199d190
< def __enter__(self) -> BinaryIO:
< ...
< def __exit__(self, typ, exc, tb) -> bool:
< ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment