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
8b59514e
Commit
8b59514e
authored
Aug 25, 2005
by
Martin v. Löwis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make IDNA return an empty string when the input is empty. Fixes #1163178.
Will backport to 2.4.
parent
8246c439
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
0 deletions
+14
-0
Lib/encodings/idna.py
Lib/encodings/idna.py
+6
-0
Lib/test/test_codecs.py
Lib/test/test_codecs.py
+6
-0
Misc/NEWS
Misc/NEWS
+2
-0
No files found.
Lib/encodings/idna.py
View file @
8b59514e
...
...
@@ -149,6 +149,9 @@ class Codec(codecs.Codec):
# IDNA is quite clear that implementations must be strict
raise
UnicodeError
,
"unsupported error handling "
+
errors
if
not
input
:
return
""
,
0
result
=
[]
labels
=
dots
.
split
(
input
)
if
labels
and
len
(
labels
[
-
1
])
==
0
:
...
...
@@ -166,6 +169,9 @@ class Codec(codecs.Codec):
if
errors
!=
'strict'
:
raise
UnicodeError
,
"Unsupported error handling "
+
errors
if
not
input
:
return
u""
,
0
# IDNA allows decoding to operate on Unicode strings, too.
if
isinstance
(
input
,
unicode
):
labels
=
dots
.
split
(
input
)
...
...
Lib/test/test_codecs.py
View file @
8b59514e
...
...
@@ -630,6 +630,12 @@ class CodecTest(unittest.TestCase):
def
test_builtin
(
self
):
self
.
assertEquals
(
unicode
(
"python.org"
,
"idna"
),
u"python.org"
)
def
test_stream
(
self
):
import
StringIO
r
=
codecs
.
getreader
(
"idna"
)(
StringIO
.
StringIO
(
"abc"
))
r
.
read
(
3
)
self
.
assertEquals
(
r
.
read
(),
u""
)
class
CodecsModuleTest
(
unittest
.
TestCase
):
def
test_decode
(
self
):
...
...
Misc/NEWS
View file @
8b59514e
...
...
@@ -193,6 +193,8 @@ Extension Modules
Library
-------
-
Bug
#
1163178
:
Make
IDNA
return
an
empty
string
when
the
input
is
empty
.
-
Patch
#
848017
:
Make
Cookie
more
RFC
-
compliant
.
Use
CRLF
as
default
output
separator
and
do
not
output
trailing
semicola
.
...
...
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