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
074f3793
Commit
074f3793
authored
Mar 10, 2000
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Marc-Andre Lemburg: support marshalling Unicode objects (code 'u').
parent
2017d6aa
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
5 deletions
+42
-5
Python/marshal.c
Python/marshal.c
+42
-5
No files found.
Python/marshal.c
View file @
074f3793
...
...
@@ -52,6 +52,7 @@ PERFORMANCE OF THIS SOFTWARE.
#define TYPE_LIST '['
#define TYPE_DICT '{'
#define TYPE_CODE 'c'
#define TYPE_UNICODE 'u'
#define TYPE_UNKNOWN '?'
typedef
struct
{
...
...
@@ -213,9 +214,22 @@ w_object(v, p)
#endif
else
if
(
PyString_Check
(
v
))
{
w_byte
(
TYPE_STRING
,
p
);
n
=
PyString_
Size
(
v
);
n
=
PyString_
GET_SIZE
(
v
);
w_long
((
long
)
n
,
p
);
w_string
(
PyString_AsString
(
v
),
n
,
p
);
w_string
(
PyString_AS_STRING
(
v
),
n
,
p
);
}
else
if
(
PyUnicode_Check
(
v
))
{
PyObject
*
utf8
;
utf8
=
PyUnicode_AsUTF8String
(
v
);
if
(
utf8
==
NULL
)
{
p
->
error
=
1
;
return
;
}
w_byte
(
TYPE_UNICODE
,
p
);
n
=
PyString_GET_SIZE
(
utf8
);
w_long
((
long
)
n
,
p
);
w_string
(
PyString_AS_STRING
(
utf8
),
n
,
p
);
Py_DECREF
(
utf8
);
}
else
if
(
PyTuple_Check
(
v
))
{
w_byte
(
TYPE_TUPLE
,
p
);
...
...
@@ -227,10 +241,10 @@ w_object(v, p)
}
else
if
(
PyList_Check
(
v
))
{
w_byte
(
TYPE_LIST
,
p
);
n
=
PyList_
Size
(
v
);
n
=
PyList_
GET_SIZE
(
v
);
w_long
((
long
)
n
,
p
);
for
(
i
=
0
;
i
<
n
;
i
++
)
{
w_object
(
PyList_G
etItem
(
v
,
i
),
p
);
w_object
(
PyList_G
ET_ITEM
(
v
,
i
),
p
);
}
}
else
if
(
PyDict_Check
(
v
))
{
...
...
@@ -482,7 +496,7 @@ r_object(p)
}
v
=
PyString_FromStringAndSize
((
char
*
)
NULL
,
n
);
if
(
v
!=
NULL
)
{
if
(
r_string
(
PyString_A
sString
(
v
),
(
int
)
n
,
p
)
!=
n
)
{
if
(
r_string
(
PyString_A
S_STRING
(
v
),
(
int
)
n
,
p
)
!=
n
)
{
Py_DECREF
(
v
);
v
=
NULL
;
PyErr_SetString
(
PyExc_EOFError
,
...
...
@@ -491,6 +505,29 @@ r_object(p)
}
return
v
;
case
TYPE_UNICODE
:
{
char
*
buffer
;
n
=
r_long
(
p
);
if
(
n
<
0
)
{
PyErr_SetString
(
PyExc_ValueError
,
"bad marshal data"
);
return
NULL
;
}
buffer
=
(
char
*
)
Py_Malloc
(
n
);
if
(
buffer
==
NULL
)
return
NULL
;
if
(
r_string
(
buffer
,
(
int
)
n
,
p
)
!=
n
)
{
free
(
buffer
);
PyErr_SetString
(
PyExc_EOFError
,
"EOF read where object expected"
);
return
NULL
;
}
v
=
PyUnicode_DecodeUTF8
(
buffer
,
n
,
NULL
);
free
(
buffer
);
return
v
;
}
case
TYPE_TUPLE
:
n
=
r_long
(
p
);
if
(
n
<
0
)
{
...
...
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