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
b0e8e9b7
Commit
b0e8e9b7
authored
Sep 10, 2001
by
Fredrik Lundh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more xmlrpclib tweaks: fixed repr(Fault()); enable UTF-8 parsing in
xmllib (on 2.0 and later)
parent
7a50f253
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
12 deletions
+17
-12
Lib/xmlrpclib.py
Lib/xmlrpclib.py
+17
-12
No files found.
Lib/xmlrpclib.py
View file @
b0e8e9b7
...
@@ -166,11 +166,13 @@ __version__ = "1.0b3"
...
@@ -166,11 +166,13 @@ __version__ = "1.0b3"
class
Error
(
Exception
):
class
Error
(
Exception
):
"""Base class for client errors."""
"""Base class for client errors."""
pass
def
__str__
(
self
):
return
repr
(
self
)
class
ProtocolError
(
Error
):
class
ProtocolError
(
Error
):
"""Indicates an HTTP protocol error."""
"""Indicates an HTTP protocol error."""
def
__init__
(
self
,
url
,
errcode
,
errmsg
,
headers
):
def
__init__
(
self
,
url
,
errcode
,
errmsg
,
headers
):
Error
.
__init__
(
self
)
self
.
url
=
url
self
.
url
=
url
self
.
errcode
=
errcode
self
.
errcode
=
errcode
self
.
errmsg
=
errmsg
self
.
errmsg
=
errmsg
...
@@ -188,12 +190,13 @@ class ResponseError(Error):
...
@@ -188,12 +190,13 @@ class ResponseError(Error):
class
Fault
(
Error
):
class
Fault
(
Error
):
"""Indicates an XML-RPC fault package."""
"""Indicates an XML-RPC fault package."""
def
__init__
(
self
,
faultCode
,
faultString
,
**
extra
):
def
__init__
(
self
,
faultCode
,
faultString
,
**
extra
):
Error
.
__init__
(
self
)
self
.
faultCode
=
faultCode
self
.
faultCode
=
faultCode
self
.
faultString
=
faultString
self
.
faultString
=
faultString
def
__repr__
(
self
):
def
__repr__
(
self
):
return
(
return
(
"<Fault %s: %s>"
%
"<Fault %s: %s>"
%
(
repr
(
self
.
faultCode
)
,
repr
(
self
.
faultString
))
(
self
.
faultCode
,
repr
(
self
.
faultString
))
)
)
# --------------------------------------------------------------------
# --------------------------------------------------------------------
...
@@ -399,8 +402,10 @@ class SlowParser:
...
@@ -399,8 +402,10 @@ class SlowParser:
self
.
unknown_starttag
=
target
.
start
self
.
unknown_starttag
=
target
.
start
self
.
handle_data
=
target
.
data
self
.
handle_data
=
target
.
data
self
.
unknown_endtag
=
target
.
end
self
.
unknown_endtag
=
target
.
end
xmllib
.
XMLParser
.
__init__
(
self
)
try
:
xmllib
.
XMLParser
.
__init__
(
self
,
accept_utf8
=
1
)
except
TypeError
:
xmllib
.
XMLParser
.
__init__
(
self
)
# pre-2.0
# --------------------------------------------------------------------
# --------------------------------------------------------------------
# XML-RPC marshalling and unmarshalling code
# XML-RPC marshalling and unmarshalling code
...
@@ -521,11 +526,11 @@ class Marshaller:
...
@@ -521,11 +526,11 @@ class Marshaller:
class
Unmarshaller
:
class
Unmarshaller
:
"""Unmarshal an XML-RPC response, based on incoming XML event
"""Unmarshal an XML-RPC response, based on incoming XML event
messages (start, data, end). Call close to get the resulting
messages (start, data, end). Call close
()
to get the resulting
data structure.
data structure.
Note that this reader is fairly tolerant, and gladly accepts
Note that this reader is fairly tolerant, and gladly accepts
bogus
bogus
XML-RPC data without complaining (but not bogus XML).
XML-RPC data without complaining (but not bogus XML).
"""
"""
# and again, if you don't understand what's going on in here,
# and again, if you don't understand what's going on in here,
...
@@ -688,8 +693,8 @@ class Unmarshaller:
...
@@ -688,8 +693,8 @@ class Unmarshaller:
def
getparser
():
def
getparser
():
"""getparser() -> parser, unmarshaller
"""getparser() -> parser, unmarshaller
Create an instance of the fastest available parser, and attach
Create an instance of the fastest available parser, and attach
it
it
to an unmarshalling object. Return both objects.
to an unmarshalling object. Return both objects.
"""
"""
if
FastParser
and
FastUnmarshaller
:
if
FastParser
and
FastUnmarshaller
:
target
=
FastUnmarshaller
(
True
,
False
,
binary
,
datetime
)
target
=
FastUnmarshaller
(
True
,
False
,
binary
,
datetime
)
...
@@ -712,8 +717,8 @@ def dumps(params, methodname=None, methodresponse=None, encoding=None):
...
@@ -712,8 +717,8 @@ def dumps(params, methodname=None, methodresponse=None, encoding=None):
Convert an argument tuple or a Fault instance to an XML-RPC
Convert an argument tuple or a Fault instance to an XML-RPC
request (or response, if the methodresponse option is used).
request (or response, if the methodresponse option is used).
In addition to the data object, the following options can be
In addition to the data object, the following options can be
given
given
as keyword arguments:
as keyword arguments:
methodname: the method name for a methodCall packet
methodname: the method name for a methodCall packet
...
@@ -725,7 +730,7 @@ def dumps(params, methodname=None, methodresponse=None, encoding=None):
...
@@ -725,7 +730,7 @@ def dumps(params, methodname=None, methodresponse=None, encoding=None):
All 8-bit strings in the data structure are assumed to use the
All 8-bit strings in the data structure are assumed to use the
packet encoding. Unicode strings are automatically converted,
packet encoding. Unicode strings are automatically converted,
as
necessary.
where
necessary.
"""
"""
assert
isinstance
(
params
,
TupleType
)
or
isinstance
(
params
,
Fault
),
\
assert
isinstance
(
params
,
TupleType
)
or
isinstance
(
params
,
Fault
),
\
...
...
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