Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
8afc8f61
Commit
8afc8f61
authored
Nov 22, 2013
by
Nick Coghlan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #19619: Update What's New for codec blacklist
parent
c72e4e6d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
11 deletions
+12
-11
Doc/whatsnew/3.4.rst
Doc/whatsnew/3.4.rst
+12
-11
No files found.
Doc/whatsnew/3.4.rst
View file @
8afc8f61
...
...
@@ -194,37 +194,37 @@ in both Python 2 and Python 3, rather than being limited to Unicode text
encodings (in Python 3) or ``basestring`` <-> ``basestring`` conversions
(in Python 2).
In Python 3.4, the
errors raised by the convenience methods when a codec
produces the incorrect output type have also been updated to direct users
towards these general purpose convenience functions
::
In Python 3.4, the
interpreter is able to identify the known non-text
encodings provided in the standard library and direct users towards these
general purpose convenience functions when appropriate
::
>>> import codecs
>>>
codecs.encode(b"hello", "bz2_codec").decode("bz2
_codec")
>>>
b"abcdef".decode("hex
_codec")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'bz2_codec' decoder returned 'bytes' instead of 'str'; use codecs.decode() to decode to arbitrary type
s
LookupError: 'hex_codec' is not a text encoding; use codecs.decode() to handle arbitrary codec
s
>>> "hello".encode("rot_13")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'rot_13' encoder returned 'str' instead of 'bytes'; use codecs.encode() to encode to arbitrary type
s
LookupError: 'rot_13' is not a text encoding; use codecs.encode() to handle arbitrary codec
s
In a related change, whenever it is feasible without breaking backwards
compatibility, exceptions raised during encoding and decoding operations
will be wrapped in a chained exception of the same type that mentions the
name of the codec responsible for producing the error::
>>>
b"hello".decode("uu
_codec")
ValueError: Missing "begin" line in input data
>>>
codecs.decode(b"abcdefgh", "hex
_codec")
binascii.Error: Non-hexadecimal digit found
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: decoding with 'uu_codec' codec failed (ValueError: Missing "begin" line in input data
)
binascii.Error: decoding with 'hex_codec' codec failed (Error: Non-hexadecimal digit found
)
>>>
"hello".encode(
"bz2_codec")
>>>
codecs.encode("hello",
"bz2_codec")
TypeError: 'str' does not support the buffer interface
The above exception was the direct cause of the following exception:
...
...
@@ -233,7 +233,8 @@ name of the codec responsible for producing the error::
File "<stdin>", line 1, in <module>
TypeError: encoding with 'bz2_codec' codec failed (TypeError: 'str' does not support the buffer interface)
(Contributed by Nick Coghlan in :issue:`17827` and :issue:`17828`)
(Contributed by Nick Coghlan in :issue:`17827`, :issue:`17828` and
:issue:`19619`)
Other Language Changes
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment