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
4637309e
Commit
4637309e
authored
Oct 04, 2011
by
Charles-François Natali
Browse files
Options
Browse Files
Download
Plain Diff
Merge.
parents
09252c49
e1335c71
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
60 additions
and
17 deletions
+60
-17
Modules/_io/stringio.c
Modules/_io/stringio.c
+4
-0
Objects/unicodeobject.c
Objects/unicodeobject.c
+42
-10
Python/getargs.c
Python/getargs.c
+14
-7
No files found.
Modules/_io/stringio.c
View file @
4637309e
...
@@ -131,6 +131,10 @@ write_str(stringio *self, PyObject *obj)
...
@@ -131,6 +131,10 @@ write_str(stringio *self, PyObject *obj)
return
-
1
;
return
-
1
;
assert
(
PyUnicode_Check
(
decoded
));
assert
(
PyUnicode_Check
(
decoded
));
if
(
PyUnicode_READY
(
decoded
))
{
Py_DECREF
(
decoded
);
return
-
1
;
}
len
=
PyUnicode_GET_LENGTH
(
decoded
);
len
=
PyUnicode_GET_LENGTH
(
decoded
);
assert
(
len
>=
0
);
assert
(
len
>=
0
);
...
...
Objects/unicodeobject.c
View file @
4637309e
...
@@ -2120,6 +2120,10 @@ PyUnicode_FromFormatV(const char *format, va_list vargs)
...
@@ -2120,6 +2120,10 @@ PyUnicode_FromFormatV(const char *format, va_list vargs)
str_obj
=
PyUnicode_DecodeUTF8
(
str
,
strlen
(
str
),
"replace"
);
str_obj
=
PyUnicode_DecodeUTF8
(
str
,
strlen
(
str
),
"replace"
);
if
(
!
str_obj
)
if
(
!
str_obj
)
goto
fail
;
goto
fail
;
if
(
PyUnicode_READY
(
str_obj
))
{
Py_DECREF
(
str_obj
);
goto
fail
;
}
argmaxchar
=
PyUnicode_MAX_CHAR_VALUE
(
str_obj
);
argmaxchar
=
PyUnicode_MAX_CHAR_VALUE
(
str_obj
);
maxchar
=
Py_MAX
(
maxchar
,
argmaxchar
);
maxchar
=
Py_MAX
(
maxchar
,
argmaxchar
);
n
+=
PyUnicode_GET_LENGTH
(
str_obj
);
n
+=
PyUnicode_GET_LENGTH
(
str_obj
);
...
@@ -2625,10 +2629,12 @@ PyUnicode_Decode(const char *s,
...
@@ -2625,10 +2629,12 @@ PyUnicode_Decode(const char *s,
goto
onError
;
goto
onError
;
}
}
Py_DECREF
(
buffer
);
Py_DECREF
(
buffer
);
#ifndef DONT_MAKE_RESULT_READY
if
(
_PyUnicode_READY_REPLACE
(
&
unicode
))
{
if
(
_PyUnicode_READY_REPLACE
(
&
unicode
))
{
Py_DECREF
(
unicode
);
Py_DECREF
(
unicode
);
return
NULL
;
return
NULL
;
}
}
#endif
return
unicode
;
return
unicode
;
onError:
onError:
...
@@ -3674,10 +3680,12 @@ utf7Error:
...
@@ -3674,10 +3680,12 @@ utf7Error:
Py_XDECREF
(
errorHandler
);
Py_XDECREF
(
errorHandler
);
Py_XDECREF
(
exc
);
Py_XDECREF
(
exc
);
#ifndef DONT_MAKE_RESULT_READY
if
(
_PyUnicode_READY_REPLACE
(
&
unicode
))
{
if
(
_PyUnicode_READY_REPLACE
(
&
unicode
))
{
Py_DECREF
(
unicode
);
Py_DECREF
(
unicode
);
return
NULL
;
return
NULL
;
}
}
#endif
return
(
PyObject
*
)
unicode
;
return
(
PyObject
*
)
unicode
;
onError:
onError:
...
@@ -4244,10 +4252,12 @@ PyUnicode_DecodeUTF8Stateful(const char *s,
...
@@ -4244,10 +4252,12 @@ PyUnicode_DecodeUTF8Stateful(const char *s,
Py_XDECREF
(
errorHandler
);
Py_XDECREF
(
errorHandler
);
Py_XDECREF
(
exc
);
Py_XDECREF
(
exc
);
#ifndef DONT_MAKE_RESULT_READY
if
(
_PyUnicode_READY_REPLACE
(
&
unicode
))
{
if
(
_PyUnicode_READY_REPLACE
(
&
unicode
))
{
Py_DECREF
(
unicode
);
Py_DECREF
(
unicode
);
return
NULL
;
return
NULL
;
}
}
#endif
return
(
PyObject
*
)
unicode
;
return
(
PyObject
*
)
unicode
;
onError:
onError:
...
@@ -4747,10 +4757,12 @@ PyUnicode_DecodeUTF32Stateful(const char *s,
...
@@ -4747,10 +4757,12 @@ PyUnicode_DecodeUTF32Stateful(const char *s,
Py_XDECREF
(
errorHandler
);
Py_XDECREF
(
errorHandler
);
Py_XDECREF
(
exc
);
Py_XDECREF
(
exc
);
#ifndef DONT_MAKE_RESULT_READY
if
(
_PyUnicode_READY_REPLACE
(
&
unicode
))
{
if
(
_PyUnicode_READY_REPLACE
(
&
unicode
))
{
Py_DECREF
(
unicode
);
Py_DECREF
(
unicode
);
return
NULL
;
return
NULL
;
}
}
#endif
return
(
PyObject
*
)
unicode
;
return
(
PyObject
*
)
unicode
;
onError:
onError:
...
@@ -5145,10 +5157,12 @@ PyUnicode_DecodeUTF16Stateful(const char *s,
...
@@ -5145,10 +5157,12 @@ PyUnicode_DecodeUTF16Stateful(const char *s,
Py_XDECREF
(
errorHandler
);
Py_XDECREF
(
errorHandler
);
Py_XDECREF
(
exc
);
Py_XDECREF
(
exc
);
#ifndef DONT_MAKE_RESULT_READY
if
(
_PyUnicode_READY_REPLACE
(
&
unicode
))
{
if
(
_PyUnicode_READY_REPLACE
(
&
unicode
))
{
Py_DECREF
(
unicode
);
Py_DECREF
(
unicode
);
return
NULL
;
return
NULL
;
}
}
#endif
return
(
PyObject
*
)
unicode
;
return
(
PyObject
*
)
unicode
;
onError:
onError:
...
@@ -5604,10 +5618,12 @@ PyUnicode_DecodeUnicodeEscape(const char *s,
...
@@ -5604,10 +5618,12 @@ PyUnicode_DecodeUnicodeEscape(const char *s,
}
}
Py_XDECREF
(
errorHandler
);
Py_XDECREF
(
errorHandler
);
Py_XDECREF
(
exc
);
Py_XDECREF
(
exc
);
#ifndef DONT_MAKE_RESULT_READY
if
(
_PyUnicode_READY_REPLACE
(
&
v
))
{
if
(
_PyUnicode_READY_REPLACE
(
&
v
))
{
Py_DECREF
(
v
);
Py_DECREF
(
v
);
return
NULL
;
return
NULL
;
}
}
#endif
return
(
PyObject
*
)
v
;
return
(
PyObject
*
)
v
;
ucnhashError:
ucnhashError:
...
@@ -5905,10 +5921,12 @@ PyUnicode_DecodeRawUnicodeEscape(const char *s,
...
@@ -5905,10 +5921,12 @@ PyUnicode_DecodeRawUnicodeEscape(const char *s,
goto
onError
;
goto
onError
;
Py_XDECREF
(
errorHandler
);
Py_XDECREF
(
errorHandler
);
Py_XDECREF
(
exc
);
Py_XDECREF
(
exc
);
#ifndef DONT_MAKE_RESULT_READY
if
(
_PyUnicode_READY_REPLACE
(
&
v
))
{
if
(
_PyUnicode_READY_REPLACE
(
&
v
))
{
Py_DECREF
(
v
);
Py_DECREF
(
v
);
return
NULL
;
return
NULL
;
}
}
#endif
return
(
PyObject
*
)
v
;
return
(
PyObject
*
)
v
;
onError:
onError:
...
@@ -6093,10 +6111,12 @@ _PyUnicode_DecodeUnicodeInternal(const char *s,
...
@@ -6093,10 +6111,12 @@ _PyUnicode_DecodeUnicodeInternal(const char *s,
goto
onError
;
goto
onError
;
Py_XDECREF
(
errorHandler
);
Py_XDECREF
(
errorHandler
);
Py_XDECREF
(
exc
);
Py_XDECREF
(
exc
);
#ifndef DONT_MAKE_RESULT_READY
if
(
_PyUnicode_READY_REPLACE
(
&
v
))
{
if
(
_PyUnicode_READY_REPLACE
(
&
v
))
{
Py_DECREF
(
v
);
Py_DECREF
(
v
);
return
NULL
;
return
NULL
;
}
}
#endif
return
(
PyObject
*
)
v
;
return
(
PyObject
*
)
v
;
onError:
onError:
...
@@ -6519,10 +6539,12 @@ PyUnicode_DecodeASCII(const char *s,
...
@@ -6519,10 +6539,12 @@ PyUnicode_DecodeASCII(const char *s,
goto
onError
;
goto
onError
;
Py_XDECREF
(
errorHandler
);
Py_XDECREF
(
errorHandler
);
Py_XDECREF
(
exc
);
Py_XDECREF
(
exc
);
#ifndef DONT_MAKE_RESULT_READY
if
(
_PyUnicode_READY_REPLACE
(
&
v
))
{
if
(
_PyUnicode_READY_REPLACE
(
&
v
))
{
Py_DECREF
(
v
);
Py_DECREF
(
v
);
return
NULL
;
return
NULL
;
}
}
#endif
return
(
PyObject
*
)
v
;
return
(
PyObject
*
)
v
;
onError:
onError:
...
@@ -6713,10 +6735,12 @@ PyUnicode_DecodeMBCSStateful(const char *s,
...
@@ -6713,10 +6735,12 @@ PyUnicode_DecodeMBCSStateful(const char *s,
goto
retry
;
goto
retry
;
}
}
#endif
#endif
#ifndef DONT_MAKE_RESULT_READY
if
(
_PyUnicode_READY_REPLACE
(
&
v
))
{
if
(
_PyUnicode_READY_REPLACE
(
&
v
))
{
Py_DECREF
(
v
);
Py_DECREF
(
v
);
return
NULL
;
return
NULL
;
}
}
#endif
return
(
PyObject
*
)
v
;
return
(
PyObject
*
)
v
;
}
}
...
@@ -7012,10 +7036,12 @@ PyUnicode_DecodeCharmap(const char *s,
...
@@ -7012,10 +7036,12 @@ PyUnicode_DecodeCharmap(const char *s,
goto
onError
;
goto
onError
;
Py_XDECREF
(
errorHandler
);
Py_XDECREF
(
errorHandler
);
Py_XDECREF
(
exc
);
Py_XDECREF
(
exc
);
#ifndef DONT_MAKE_RESULT_READY
if
(
_PyUnicode_READY_REPLACE
(
&
v
))
{
if
(
_PyUnicode_READY_REPLACE
(
&
v
))
{
Py_DECREF
(
v
);
Py_DECREF
(
v
);
return
NULL
;
return
NULL
;
}
}
#endif
return
(
PyObject
*
)
v
;
return
(
PyObject
*
)
v
;
onError:
onError:
...
@@ -8057,10 +8083,12 @@ PyUnicode_TransformDecimalToASCII(Py_UNICODE *s,
...
@@ -8057,10 +8083,12 @@ PyUnicode_TransformDecimalToASCII(Py_UNICODE *s,
p
[
i
]
=
'0'
+
decimal
;
p
[
i
]
=
'0'
+
decimal
;
}
}
}
}
if
(
PyUnicode_READY
((
PyUnicodeObject
*
)
result
)
==
-
1
)
{
#ifndef DONT_MAKE_RESULT_READY
if
(
_PyUnicode_READY_REPLACE
(
&
result
))
{
Py_DECREF
(
result
);
Py_DECREF
(
result
);
return
NULL
;
return
NULL
;
}
}
#endif
return
result
;
return
result
;
}
}
/* --- Decimal Encoder ---------------------------------------------------- */
/* --- Decimal Encoder ---------------------------------------------------- */
...
@@ -10038,17 +10066,17 @@ PyUnicode_Append(PyObject **p_left, PyObject *right)
...
@@ -10038,17 +10066,17 @@ PyUnicode_Append(PyObject **p_left, PyObject *right)
goto
error
;
goto
error
;
}
}
if
(
PyUnicode_READY
(
left
))
goto
error
;
if
(
PyUnicode_READY
(
right
))
goto
error
;
if
(
PyUnicode_CheckExact
(
left
)
&&
left
!=
unicode_empty
if
(
PyUnicode_CheckExact
(
left
)
&&
left
!=
unicode_empty
&&
PyUnicode_CheckExact
(
right
)
&&
right
!=
unicode_empty
&&
PyUnicode_CheckExact
(
right
)
&&
right
!=
unicode_empty
&&
unicode_resizable
(
left
)
&&
unicode_resizable
(
left
)
&&
(
_PyUnicode_KIND
(
right
)
<=
_PyUnicode_KIND
(
left
)
&&
(
_PyUnicode_KIND
(
right
)
<=
_PyUnicode_KIND
(
left
)
||
_PyUnicode_WSTR
(
left
)
!=
NULL
))
||
_PyUnicode_WSTR
(
left
)
!=
NULL
))
{
{
if
(
PyUnicode_READY
(
left
))
goto
error
;
if
(
PyUnicode_READY
(
right
))
goto
error
;
/* Don't resize for ascii += latin1. Convert ascii to latin1 requires
/* Don't resize for ascii += latin1. Convert ascii to latin1 requires
to change the structure size, but characters are stored just after
to change the structure size, but characters are stored just after
the structure, and so it requires to move all charactres which is
the structure, and so it requires to move all charactres which is
...
@@ -10265,10 +10293,12 @@ unicode_expandtabs(PyUnicodeObject *self, PyObject *args)
...
@@ -10265,10 +10293,12 @@ unicode_expandtabs(PyUnicodeObject *self, PyObject *args)
}
}
}
}
assert
(
j
==
PyUnicode_GET_LENGTH
(
u
));
assert
(
j
==
PyUnicode_GET_LENGTH
(
u
));
if
(
PyUnicode_READY
(
u
))
{
#ifndef DONT_MAKE_RESULT_READY
if
(
_PyUnicode_READY_REPLACE
(
&
u
))
{
Py_DECREF
(
u
);
Py_DECREF
(
u
);
return
NULL
;
return
NULL
;
}
}
#endif
return
(
PyObject
*
)
u
;
return
(
PyObject
*
)
u
;
overflow:
overflow:
...
@@ -12923,7 +12953,7 @@ unicode_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
...
@@ -12923,7 +12953,7 @@ unicode_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if
(
unicode
==
NULL
)
if
(
unicode
==
NULL
)
return
NULL
;
return
NULL
;
assert
(
_PyUnicode_CHECK
(
unicode
));
assert
(
_PyUnicode_CHECK
(
unicode
));
if
(
_PyUnicode_READY_REPLACE
(
&
unicode
))
if
(
PyUnicode_READY
(
unicode
))
return
NULL
;
return
NULL
;
self
=
(
PyUnicodeObject
*
)
type
->
tp_alloc
(
type
,
0
);
self
=
(
PyUnicodeObject
*
)
type
->
tp_alloc
(
type
,
0
);
...
@@ -13131,7 +13161,7 @@ PyUnicode_InternInPlace(PyObject **p)
...
@@ -13131,7 +13161,7 @@ PyUnicode_InternInPlace(PyObject **p)
if
(
PyUnicode_CHECK_INTERNED
(
s
))
if
(
PyUnicode_CHECK_INTERNED
(
s
))
return
;
return
;
if
(
_PyUnicode_READY_REPLACE
(
p
))
{
if
(
_PyUnicode_READY_REPLACE
(
p
))
{
assert
(
0
&&
"
PyUnicode_READY
fail in PyUnicode_InternInPlace"
);
assert
(
0
&&
"
_PyUnicode_READY_REPLACE
fail in PyUnicode_InternInPlace"
);
return
;
return
;
}
}
s
=
(
PyUnicodeObject
*
)(
*
p
);
s
=
(
PyUnicodeObject
*
)(
*
p
);
...
@@ -13217,8 +13247,10 @@ _Py_ReleaseInternedUnicodeStrings(void)
...
@@ -13217,8 +13247,10 @@ _Py_ReleaseInternedUnicodeStrings(void)
n
);
n
);
for
(
i
=
0
;
i
<
n
;
i
++
)
{
for
(
i
=
0
;
i
<
n
;
i
++
)
{
s
=
(
PyUnicodeObject
*
)
PyList_GET_ITEM
(
keys
,
i
);
s
=
(
PyUnicodeObject
*
)
PyList_GET_ITEM
(
keys
,
i
);
if
(
PyUnicode_READY
(
s
)
==
-
1
)
if
(
PyUnicode_READY
(
s
)
==
-
1
)
{
assert
(
0
&&
"could not ready string"
);
fprintf
(
stderr
,
"could not ready string
\n
"
);
fprintf
(
stderr
,
"could not ready string
\n
"
);
}
switch
(
PyUnicode_CHECK_INTERNED
(
s
))
{
switch
(
PyUnicode_CHECK_INTERNED
(
s
))
{
case
SSTATE_NOT_INTERNED
:
case
SSTATE_NOT_INTERNED
:
/* XXX Shouldn't happen */
/* XXX Shouldn't happen */
...
...
Python/getargs.c
View file @
4637309e
...
@@ -834,14 +834,21 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
...
@@ -834,14 +834,21 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
case
'C'
:
{
/* unicode char */
case
'C'
:
{
/* unicode char */
int
*
p
=
va_arg
(
*
p_va
,
int
*
);
int
*
p
=
va_arg
(
*
p_va
,
int
*
);
if
(
PyUnicode_Check
(
arg
)
&&
int
kind
;
PyUnicode_GET_LENGTH
(
arg
)
==
1
)
{
void
*
data
;
int
kind
=
PyUnicode_KIND
(
arg
);
void
*
data
=
PyUnicode_DATA
(
arg
);
if
(
!
PyUnicode_Check
(
arg
))
*
p
=
PyUnicode_READ
(
kind
,
data
,
0
);
return
converterr
(
"a unicode character"
,
arg
,
msgbuf
,
bufsize
);
}
else
if
(
PyUnicode_READY
(
arg
))
RETURN_ERR_OCCURRED
;
if
(
PyUnicode_GET_LENGTH
(
arg
)
!=
1
)
return
converterr
(
"a unicode character"
,
arg
,
msgbuf
,
bufsize
);
return
converterr
(
"a unicode character"
,
arg
,
msgbuf
,
bufsize
);
kind
=
PyUnicode_KIND
(
arg
);
data
=
PyUnicode_DATA
(
arg
);
*
p
=
PyUnicode_READ
(
kind
,
data
,
0
);
break
;
break
;
}
}
...
...
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