Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
X
xml_marshaller
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
xml_marshaller
Commits
6f4488a5
Commit
6f4488a5
authored
Feb 22, 2019
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
xml_marshaller: fix dump of bytes with Python 2 and update tests
parent
3e793e44
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
7 deletions
+9
-7
README.txt
README.txt
+4
-4
src/xml_marshaller/tests/test_xml_marshaller.py
src/xml_marshaller/tests/test_xml_marshaller.py
+2
-2
src/xml_marshaller/xml_marshaller.py
src/xml_marshaller/xml_marshaller.py
+3
-1
No files found.
README.txt
View file @
6f4488a5
...
@@ -29,10 +29,10 @@ For simple serialisation and unserialisation::
...
@@ -29,10 +29,10 @@ For simple serialisation and unserialisation::
>>> from xml_marshaller import xml_marshaller
>>> from xml_marshaller import xml_marshaller
>>> xml_marshaller.dumps(['item1', {'key1': 1, 'key2':
u'unicode
string'}])
>>> xml_marshaller.dumps(['item1', {'key1': 1, 'key2':
'
string'}])
'<marshal><list id="i2"><string>item1</string><dictionary id="i3"><string>key1</string><int>1</int><string>key2</string><
unicode>unicode string</unicode
></dictionary></list></marshal>'
'<marshal><list id="i2"><string>item1</string><dictionary id="i3"><string>key1</string><int>1</int><string>key2</string><
string>string</string
></dictionary></list></marshal>'
>>> xml_marshaller.loads(xml_marshaller.dumps(['item1', {'key1': 1, 'key2':
u'unicode
string'}]))
>>> xml_marshaller.loads(xml_marshaller.dumps(['item1', {'key1': 1, 'key2':
'
string'}]))
['item1', {'key2':
u'unicode
string', 'key1': 1}]
['item1', {'key2':
'
string', 'key1': 1}]
Can works with file like objects::
Can works with file like objects::
...
...
src/xml_marshaller/tests/test_xml_marshaller.py
View file @
6f4488a5
...
@@ -60,7 +60,7 @@ class TestXMLMarhsaller(unittest.TestCase):
...
@@ -60,7 +60,7 @@ class TestXMLMarhsaller(unittest.TestCase):
[
'alpha'
,
'beta'
,
'gamma'
,
[
None
,
1
,
1
<<
123
,
19.72
,
[
'alpha'
,
'beta'
,
'gamma'
,
[
None
,
1
,
1
<<
123
,
19.72
,
1
+
5j
,
"& a <fake tag>"
]],
1
+
5j
,
"& a <fake tag>"
]],
{
'key'
:
'value'
,
1
:
2
},
{
'key'
:
'value'
,
1
:
2
},
u
'éàù^ç'
,
'éàù^ç'
,
{
'a'
,
1
},
{
'a'
,
1
},
True
,
True
,
False
,
False
,
...
@@ -83,7 +83,7 @@ class TestXMLMarhsaller(unittest.TestCase):
...
@@ -83,7 +83,7 @@ class TestXMLMarhsaller(unittest.TestCase):
[
'alpha'
,
'beta'
,
'gamma'
,
[
None
,
1
,
1
<<
123
,
19.72
,
[
'alpha'
,
'beta'
,
'gamma'
,
[
None
,
1
,
1
<<
123
,
19.72
,
1
+
5j
,
"& a <fake tag>"
]],
1
+
5j
,
"& a <fake tag>"
]],
{
'key'
:
'value'
,
1
:
2
},
{
'key'
:
'value'
,
1
:
2
},
u
'éàù^ç'
,
'éàù^ç'
,
{
'a'
,
1
},
{
'a'
,
1
},
True
,
True
,
False
,
False
,
...
...
src/xml_marshaller/xml_marshaller.py
View file @
6f4488a5
...
@@ -161,7 +161,9 @@ class Marshaller(object):
...
@@ -161,7 +161,9 @@ class Marshaller(object):
def
m_bytes
(
self
,
value
,
kw
):
def
m_bytes
(
self
,
value
,
kw
):
return
self
.
m_string
(
value
.
decode
(
'utf-8'
),
kw
)
return
self
.
m_string
(
value
.
decode
(
'utf-8'
),
kw
)
m_unicode
=
m_str
if
str
is
bytes
:
m_unicode
=
m_str
m_str
=
m_bytes
def
m_int
(
self
,
value
,
kw
):
def
m_int
(
self
,
value
,
kw
):
return
(
self
.
tag_int
if
-
1e24
<
value
<
1e24
else
return
(
self
.
tag_int
if
-
1e24
<
value
<
1e24
else
...
...
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