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
5ccbf79e
Commit
5ccbf79e
authored
Jan 20, 2016
by
Serhiy Storchaka
Browse files
Options
Browse Files
Download
Plain Diff
Issue #26147: xmlrpc now works with strings not encodable with used
non-UTF-8 encoding.
parents
5d69e687
aebb6d36
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
11 deletions
+30
-11
Lib/test/test_xmlrpc.py
Lib/test/test_xmlrpc.py
+24
-6
Lib/xmlrpc/client.py
Lib/xmlrpc/client.py
+1
-3
Lib/xmlrpc/server.py
Lib/xmlrpc/server.py
+2
-2
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/test/test_xmlrpc.py
View file @
5ccbf79e
...
...
@@ -184,19 +184,26 @@ class XMLRPCTestCase(unittest.TestCase):
self
.
assertRaises
(
TypeError
,
xmlrpclib
.
dumps
,
(
arg1
,))
def
test_dump_encoding
(
self
):
value
=
'
\
u20ac
'
value
=
{
'key
\
u20ac
\
xa4
'
:
'value
\
u20ac
\
xa4
'
}
strg
=
xmlrpclib
.
dumps
((
value
,),
encoding
=
'iso-8859-15'
)
strg
=
"<?xml version='1.0' encoding='iso-8859-15'?>"
+
strg
self
.
assertEqual
(
xmlrpclib
.
loads
(
strg
)[
0
][
0
],
value
)
strg
=
strg
.
encode
(
'iso-8859-15'
)
strg
=
strg
.
encode
(
'iso-8859-15'
,
'xmlcharrefreplace'
)
self
.
assertEqual
(
xmlrpclib
.
loads
(
strg
)[
0
][
0
],
value
)
strg
=
xmlrpclib
.
dumps
((
value
,),
encoding
=
'iso-8859-15'
,
methodresponse
=
True
)
self
.
assertEqual
(
xmlrpclib
.
loads
(
strg
)[
0
][
0
],
value
)
strg
=
strg
.
encode
(
'iso-8859-15'
)
strg
=
strg
.
encode
(
'iso-8859-15'
,
'xmlcharrefreplace'
)
self
.
assertEqual
(
xmlrpclib
.
loads
(
strg
)[
0
][
0
],
value
)
methodname
=
'method
\
u20ac
\
xa4
'
strg
=
xmlrpclib
.
dumps
((
value
,),
encoding
=
'iso-8859-15'
,
methodname
=
methodname
)
self
.
assertEqual
(
xmlrpclib
.
loads
(
strg
)[
0
][
0
],
value
)
self
.
assertEqual
(
xmlrpclib
.
loads
(
strg
)[
1
],
methodname
)
def
test_dump_bytes
(
self
):
sample
=
b"my dog has fleas"
self
.
assertEqual
(
sample
,
xmlrpclib
.
Binary
(
sample
))
...
...
@@ -430,6 +437,7 @@ def http_server(evt, numrequests, requestHandler=None, encoding=None):
serv
.
register_multicall_functions
()
serv
.
register_function
(
pow
)
serv
.
register_function
(
lambda
x
,
y
:
x
+
y
,
'add'
)
serv
.
register_function
(
lambda
x
:
x
,
'têšt'
)
serv
.
register_function
(
my_function
)
testInstance
=
TestInstanceClass
()
serv
.
register_instance
(
testInstance
,
allow_dotted_names
=
True
)
...
...
@@ -599,7 +607,7 @@ class SimpleServerTestCase(BaseServerTestCase):
def
test_client_encoding
(
self
):
start_string
=
'
\
u20ac
'
end_string
=
'
\
xa
3
'
end_string
=
'
\
xa
4
'
try
:
p
=
xmlrpclib
.
ServerProxy
(
URL
,
encoding
=
'iso-8859-15'
)
...
...
@@ -611,6 +619,16 @@ class SimpleServerTestCase(BaseServerTestCase):
# protocol error; provide additional information in test output
self
.
fail
(
"%s
\
n
%s"
%
(
e
,
getattr
(
e
,
"headers"
,
""
)))
def
test_nonascii_methodname
(
self
):
try
:
p
=
xmlrpclib
.
ServerProxy
(
URL
,
encoding
=
'ascii'
)
self
.
assertEqual
(
p
.
t
êš
t
(
42
),
42
)
except
(
xmlrpclib
.
ProtocolError
,
socket
.
error
)
as
e
:
# ignore failures due to non-blocking socket unavailable errors.
if
not
is_unavailable_exception
(
e
):
# protocol error; provide additional information in test output
self
.
fail
(
"%s
\
n
%s"
%
(
e
,
getattr
(
e
,
"headers"
,
""
)))
# [ch] The test 404 is causing lots of false alarms.
def
XXXtest_404
(
self
):
# send POST with http.client, it should return 404 header and
...
...
@@ -624,7 +642,7 @@ class SimpleServerTestCase(BaseServerTestCase):
self
.
assertEqual
(
response
.
reason
,
'Not Found'
)
def
test_introspection1
(
self
):
expected_methods
=
set
([
'pow'
,
'div'
,
'my_function'
,
'add'
,
expected_methods
=
set
([
'pow'
,
'div'
,
'my_function'
,
'add'
,
'têšt'
,
'system.listMethods'
,
'system.methodHelp'
,
'system.methodSignature'
,
'system.multicall'
,
'Fixture'
])
...
...
@@ -767,7 +785,7 @@ class SimpleServerEncodingTestCase(BaseServerTestCase):
def
test_server_encoding
(
self
):
start_string
=
'
\
u20ac
'
end_string
=
'
\
xa
3
'
end_string
=
'
\
xa
4
'
try
:
p
=
xmlrpclib
.
ServerProxy
(
URL
)
...
...
Lib/xmlrpc/client.py
View file @
5ccbf79e
...
...
@@ -955,8 +955,6 @@ def dumps(params, methodname=None, methodresponse=None, encoding=None,
# standard XML-RPC wrappings
if
methodname
:
# a method call
if
not
isinstance
(
methodname
,
str
):
methodname
=
methodname
.
encode
(
encoding
)
data
=
(
xmlheader
,
"<methodCall>
\
n
"
...
...
@@ -1422,7 +1420,7 @@ class ServerProxy:
# call a method on the remote server
request
=
dumps
(
params
,
methodname
,
encoding
=
self
.
__encoding
,
allow_none
=
self
.
__allow_none
).
encode
(
self
.
__encoding
)
allow_none
=
self
.
__allow_none
).
encode
(
self
.
__encoding
,
'xmlcharrefreplace'
)
response
=
self
.
__transport
.
request
(
self
.
__host
,
...
...
Lib/xmlrpc/server.py
View file @
5ccbf79e
...
...
@@ -269,7 +269,7 @@ class SimpleXMLRPCDispatcher:
encoding
=
self
.
encoding
,
allow_none
=
self
.
allow_none
,
)
return
response
.
encode
(
self
.
encoding
)
return
response
.
encode
(
self
.
encoding
,
'xmlcharrefreplace'
)
def
system_listMethods
(
self
):
"""system.listMethods() => ['add', 'subtract', 'multiple']
...
...
@@ -622,7 +622,7 @@ class MultiPathXMLRPCServer(SimpleXMLRPCServer):
response
=
dumps
(
Fault
(
1
,
"%s:%s"
%
(
exc_type
,
exc_value
)),
encoding
=
self
.
encoding
,
allow_none
=
self
.
allow_none
)
response
=
response
.
encode
(
self
.
encoding
)
response
=
response
.
encode
(
self
.
encoding
,
'xmlcharrefreplace'
)
return
response
class
CGIXMLRPCRequestHandler
(
SimpleXMLRPCDispatcher
):
...
...
Misc/NEWS
View file @
5ccbf79e
...
...
@@ -133,6 +133,9 @@ Core and Builtins
Library
-------
- Issue #26147: xmlrpc now works with strings not encodable with used
non-UTF-8 encoding.
- Issue #25935: Garbage collector now breaks reference loops with OrderedDict.
- Issue #16620: Fixed AttributeError in msilib.Directory.glob().
...
...
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