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
519a042c
Commit
519a042c
authored
Nov 15, 2007
by
Thomas Heller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace PyObject_Unicode with PyObject_Str everywhere, and remove the
#define for PyObject_Unicode in object.h.
parent
6e8ea0fd
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
25 additions
and
26 deletions
+25
-26
Include/object.h
Include/object.h
+0
-1
Modules/_csv.c
Modules/_csv.c
+1
-1
Modules/_ctypes/callproc.c
Modules/_ctypes/callproc.c
+1
-1
Modules/_testcapimodule.c
Modules/_testcapimodule.c
+2
-2
Modules/cjkcodecs/multibytecodec.c
Modules/cjkcodecs/multibytecodec.c
+2
-2
Modules/datetimemodule.c
Modules/datetimemodule.c
+2
-2
Modules/grpmodule.c
Modules/grpmodule.c
+1
-1
Objects/exceptions.c
Objects/exceptions.c
+3
-3
Objects/stringlib/string_format.h
Objects/stringlib/string_format.h
+1
-1
Objects/stringlib/unicodedefs.h
Objects/stringlib/unicodedefs.h
+1
-1
Objects/typeobject.c
Objects/typeobject.c
+1
-1
Objects/unicodeobject.c
Objects/unicodeobject.c
+6
-6
Python/pythonrun.c
Python/pythonrun.c
+4
-4
No files found.
Include/object.h
View file @
519a042c
...
@@ -432,7 +432,6 @@ PyAPI_FUNC(void) _Py_BreakPoint(void);
...
@@ -432,7 +432,6 @@ PyAPI_FUNC(void) _Py_BreakPoint(void);
PyAPI_FUNC
(
void
)
_PyObject_Dump
(
PyObject
*
);
PyAPI_FUNC
(
void
)
_PyObject_Dump
(
PyObject
*
);
PyAPI_FUNC
(
PyObject
*
)
PyObject_Repr
(
PyObject
*
);
PyAPI_FUNC
(
PyObject
*
)
PyObject_Repr
(
PyObject
*
);
PyAPI_FUNC
(
PyObject
*
)
PyObject_Str
(
PyObject
*
);
PyAPI_FUNC
(
PyObject
*
)
PyObject_Str
(
PyObject
*
);
#define PyObject_Unicode PyObject_Str
/* Compatibility */
PyAPI_FUNC
(
int
)
PyObject_Compare
(
PyObject
*
,
PyObject
*
);
PyAPI_FUNC
(
int
)
PyObject_Compare
(
PyObject
*
,
PyObject
*
);
PyAPI_FUNC
(
PyObject
*
)
PyObject_RichCompare
(
PyObject
*
,
PyObject
*
,
int
);
PyAPI_FUNC
(
PyObject
*
)
PyObject_RichCompare
(
PyObject
*
,
PyObject
*
,
int
);
PyAPI_FUNC
(
int
)
PyObject_RichCompareBool
(
PyObject
*
,
PyObject
*
,
int
);
PyAPI_FUNC
(
int
)
PyObject_RichCompareBool
(
PyObject
*
,
PyObject
*
,
int
);
...
...
Modules/_csv.c
View file @
519a042c
...
@@ -1185,7 +1185,7 @@ csv_writerow(WriterObj *self, PyObject *seq)
...
@@ -1185,7 +1185,7 @@ csv_writerow(WriterObj *self, PyObject *seq)
else
{
else
{
PyObject
*
str
;
PyObject
*
str
;
str
=
PyObject_
Unicode
(
field
);
str
=
PyObject_
Str
(
field
);
Py_DECREF
(
field
);
Py_DECREF
(
field
);
if
(
str
==
NULL
)
if
(
str
==
NULL
)
return
NULL
;
return
NULL
;
...
...
Modules/_ctypes/callproc.c
View file @
519a042c
...
@@ -785,7 +785,7 @@ void Extend_Error_Info(PyObject *exc_class, char *fmt, ...)
...
@@ -785,7 +785,7 @@ void Extend_Error_Info(PyObject *exc_class, char *fmt, ...)
goto
error
;
goto
error
;
}
else
}
else
PyErr_Clear
();
PyErr_Clear
();
msg_str
=
PyObject_
Unicode
(
v
);
msg_str
=
PyObject_
Str
(
v
);
if
(
msg_str
)
if
(
msg_str
)
PyUnicode_AppendAndDel
(
&
s
,
msg_str
);
PyUnicode_AppendAndDel
(
&
s
,
msg_str
);
else
{
else
{
...
...
Modules/_testcapimodule.c
View file @
519a042c
...
@@ -615,12 +615,12 @@ test_long_numbits(PyObject *self)
...
@@ -615,12 +615,12 @@ test_long_numbits(PyObject *self)
return
Py_None
;
return
Py_None
;
}
}
/* Example passing NULLs to PyObject_Str(NULL)
and PyObject_Unicode(NULL)
. */
/* Example passing NULLs to PyObject_Str(NULL). */
static
PyObject
*
static
PyObject
*
test_null_strings
(
PyObject
*
self
)
test_null_strings
(
PyObject
*
self
)
{
{
PyObject
*
o1
=
PyObject_Str
(
NULL
),
*
o2
=
PyObject_
Unicode
(
NULL
);
PyObject
*
o1
=
PyObject_Str
(
NULL
),
*
o2
=
PyObject_
Str
(
NULL
);
PyObject
*
tuple
=
PyTuple_Pack
(
2
,
o1
,
o2
);
PyObject
*
tuple
=
PyTuple_Pack
(
2
,
o1
,
o2
);
Py_XDECREF
(
o1
);
Py_XDECREF
(
o1
);
Py_XDECREF
(
o2
);
Py_XDECREF
(
o2
);
...
...
Modules/cjkcodecs/multibytecodec.c
View file @
519a042c
...
@@ -552,7 +552,7 @@ MultibyteCodec_Encode(MultibyteCodecObject *self,
...
@@ -552,7 +552,7 @@ MultibyteCodec_Encode(MultibyteCodecObject *self,
if
(
PyUnicode_Check
(
arg
))
if
(
PyUnicode_Check
(
arg
))
ucvt
=
NULL
;
ucvt
=
NULL
;
else
{
else
{
arg
=
ucvt
=
PyObject_
Unicode
(
arg
);
arg
=
ucvt
=
PyObject_
Str
(
arg
);
if
(
arg
==
NULL
)
if
(
arg
==
NULL
)
return
NULL
;
return
NULL
;
else
if
(
!
PyUnicode_Check
(
arg
))
{
else
if
(
!
PyUnicode_Check
(
arg
))
{
...
@@ -728,7 +728,7 @@ encoder_encode_stateful(MultibyteStatefulEncoderContext *ctx,
...
@@ -728,7 +728,7 @@ encoder_encode_stateful(MultibyteStatefulEncoderContext *ctx,
if
(
PyUnicode_Check
(
unistr
))
if
(
PyUnicode_Check
(
unistr
))
ucvt
=
NULL
;
ucvt
=
NULL
;
else
{
else
{
unistr
=
ucvt
=
PyObject_
Unicode
(
unistr
);
unistr
=
ucvt
=
PyObject_
Str
(
unistr
);
if
(
unistr
==
NULL
)
if
(
unistr
==
NULL
)
return
NULL
;
return
NULL
;
else
if
(
!
PyUnicode_Check
(
unistr
))
{
else
if
(
!
PyUnicode_Check
(
unistr
))
{
...
...
Modules/datetimemodule.c
View file @
519a042c
...
@@ -2444,7 +2444,7 @@ date_format(PyDateTime_Date *self, PyObject *args)
...
@@ -2444,7 +2444,7 @@ date_format(PyDateTime_Date *self, PyObject *args)
/* if the format is zero length, return str(self) */
/* if the format is zero length, return str(self) */
if
(
PyUnicode_GetSize
(
format
)
==
0
)
if
(
PyUnicode_GetSize
(
format
)
==
0
)
return
PyObject_
Unicode
((
PyObject
*
)
self
);
return
PyObject_
Str
((
PyObject
*
)
self
);
return
PyObject_CallMethod
((
PyObject
*
)
self
,
"strftime"
,
"O"
,
format
);
return
PyObject_CallMethod
((
PyObject
*
)
self
,
"strftime"
,
"O"
,
format
);
}
}
...
@@ -3220,7 +3220,7 @@ time_format(PyDateTime_Time *self, PyObject *args)
...
@@ -3220,7 +3220,7 @@ time_format(PyDateTime_Time *self, PyObject *args)
/* if the format is zero length, return str(self) */
/* if the format is zero length, return str(self) */
if
(
PyUnicode_GetSize
(
format
)
==
0
)
if
(
PyUnicode_GetSize
(
format
)
==
0
)
return
PyObject_
Unicode
((
PyObject
*
)
self
);
return
PyObject_
Str
((
PyObject
*
)
self
);
return
PyObject_CallMethod
((
PyObject
*
)
self
,
"strftime"
,
"O"
,
format
);
return
PyObject_CallMethod
((
PyObject
*
)
self
,
"strftime"
,
"O"
,
format
);
}
}
...
...
Modules/grpmodule.c
View file @
519a042c
...
@@ -110,7 +110,7 @@ grp_getgrnam(PyObject *self, PyObject *pyo_name)
...
@@ -110,7 +110,7 @@ grp_getgrnam(PyObject *self, PyObject *pyo_name)
char
*
name
;
char
*
name
;
struct
group
*
p
;
struct
group
*
p
;
py_str_name
=
PyObject_
Unicode
(
pyo_name
);
py_str_name
=
PyObject_
Str
(
pyo_name
);
if
(
!
py_str_name
)
if
(
!
py_str_name
)
return
NULL
;
return
NULL
;
name
=
PyUnicode_AsString
(
py_str_name
);
name
=
PyUnicode_AsString
(
py_str_name
);
...
...
Objects/exceptions.c
View file @
519a042c
...
@@ -89,9 +89,9 @@ BaseException_str(PyBaseExceptionObject *self)
...
@@ -89,9 +89,9 @@ BaseException_str(PyBaseExceptionObject *self)
case
0
:
case
0
:
return
PyUnicode_FromString
(
""
);
return
PyUnicode_FromString
(
""
);
case
1
:
case
1
:
return
PyObject_
Unicode
(
PyTuple_GET_ITEM
(
self
->
args
,
0
));
return
PyObject_
Str
(
PyTuple_GET_ITEM
(
self
->
args
,
0
));
default:
default:
return
PyObject_
Unicode
(
self
->
args
);
return
PyObject_
Str
(
self
->
args
);
}
}
}
}
...
@@ -939,7 +939,7 @@ SyntaxError_str(PySyntaxErrorObject *self)
...
@@ -939,7 +939,7 @@ SyntaxError_str(PySyntaxErrorObject *self)
have_lineno
=
(
self
->
lineno
!=
NULL
)
&&
PyInt_CheckExact
(
self
->
lineno
);
have_lineno
=
(
self
->
lineno
!=
NULL
)
&&
PyInt_CheckExact
(
self
->
lineno
);
if
(
!
filename
&&
!
have_lineno
)
if
(
!
filename
&&
!
have_lineno
)
return
PyObject_
Unicode
(
self
->
msg
?
self
->
msg
:
Py_None
);
return
PyObject_
Str
(
self
->
msg
?
self
->
msg
:
Py_None
);
if
(
filename
&&
have_lineno
)
if
(
filename
&&
have_lineno
)
return
PyUnicode_FromFormat
(
"%S (%s, line %ld)"
,
return
PyUnicode_FromFormat
(
"%S (%s, line %ld)"
,
...
...
Objects/stringlib/string_format.h
View file @
519a042c
...
@@ -770,7 +770,7 @@ do_conversion(PyObject *obj, STRINGLIB_CHAR conversion)
...
@@ -770,7 +770,7 @@ do_conversion(PyObject *obj, STRINGLIB_CHAR conversion)
case
'r'
:
case
'r'
:
return
PyObject_Repr
(
obj
);
return
PyObject_Repr
(
obj
);
case
's'
:
case
's'
:
return
PyObject_
Unicode
(
obj
);
return
PyObject_
Str
(
obj
);
default:
default:
PyErr_Format
(
PyExc_ValueError
,
PyErr_Format
(
PyExc_ValueError
,
"Unknown converion specifier %c"
,
"Unknown converion specifier %c"
,
...
...
Objects/stringlib/unicodedefs.h
View file @
519a042c
...
@@ -20,7 +20,7 @@
...
@@ -20,7 +20,7 @@
#define STRINGLIB_NEW PyUnicode_FromUnicode
#define STRINGLIB_NEW PyUnicode_FromUnicode
#define STRINGLIB_RESIZE PyUnicode_Resize
#define STRINGLIB_RESIZE PyUnicode_Resize
#define STRINGLIB_CHECK PyUnicode_Check
#define STRINGLIB_CHECK PyUnicode_Check
#define STRINGLIB_TOSTR PyObject_
Unicode
#define STRINGLIB_TOSTR PyObject_
Str
#define STRINGLIB_WANT_CONTAINS_OBJ 1
#define STRINGLIB_WANT_CONTAINS_OBJ 1
...
...
Objects/typeobject.c
View file @
519a042c
...
@@ -2954,7 +2954,7 @@ object_format(PyObject *self, PyObject *args)
...
@@ -2954,7 +2954,7 @@ object_format(PyObject *self, PyObject *args)
return
NULL
;
return
NULL
;
}
}
self_as_str
=
PyObject_
Unicode
(
self
);
self_as_str
=
PyObject_
Str
(
self
);
if
(
self_as_str
!=
NULL
)
{
if
(
self_as_str
!=
NULL
)
{
/* find the format function */
/* find the format function */
format_meth
=
PyObject_GetAttrString
(
self_as_str
,
"__format__"
);
format_meth
=
PyObject_GetAttrString
(
self_as_str
,
"__format__"
);
...
...
Objects/unicodeobject.c
View file @
519a042c
...
@@ -572,14 +572,14 @@ PyUnicode_FromFormatV(const char *format, va_list vargs)
...
@@ -572,14 +572,14 @@ PyUnicode_FromFormatV(const char *format, va_list vargs)
#endif
#endif
#endif
#endif
/* step 1: count the number of %S/%R format specifications
/* step 1: count the number of %S/%R format specifications
* (we call PyObject_
Unicode
()/PyObject_Repr() for these objects
* (we call PyObject_
Str
()/PyObject_Repr() for these objects
* once during step 3 and put the result in an array) */
* once during step 3 and put the result in an array) */
for
(
f
=
format
;
*
f
;
f
++
)
{
for
(
f
=
format
;
*
f
;
f
++
)
{
if
(
*
f
==
'%'
&&
(
*
(
f
+
1
)
==
'S'
||
*
(
f
+
1
)
==
'R'
))
if
(
*
f
==
'%'
&&
(
*
(
f
+
1
)
==
'S'
||
*
(
f
+
1
)
==
'R'
))
++
callcount
;
++
callcount
;
}
}
/* step 2: allocate memory for the results of
/* step 2: allocate memory for the results of
* PyObject_
Unicode
()/PyObject_Repr() calls */
* PyObject_
Str
()/PyObject_Repr() calls */
if
(
callcount
)
{
if
(
callcount
)
{
callresults
=
PyMem_Malloc
(
sizeof
(
PyObject
*
)
*
callcount
);
callresults
=
PyMem_Malloc
(
sizeof
(
PyObject
*
)
*
callcount
);
if
(
!
callresults
)
{
if
(
!
callresults
)
{
...
@@ -683,7 +683,7 @@ PyUnicode_FromFormatV(const char *format, va_list vargs)
...
@@ -683,7 +683,7 @@ PyUnicode_FromFormatV(const char *format, va_list vargs)
PyObject
*
obj
=
va_arg
(
count
,
PyObject
*
);
PyObject
*
obj
=
va_arg
(
count
,
PyObject
*
);
PyObject
*
str
;
PyObject
*
str
;
assert
(
obj
);
assert
(
obj
);
str
=
PyObject_
Unicode
(
obj
);
str
=
PyObject_
Str
(
obj
);
if
(
!
str
)
if
(
!
str
)
goto
fail
;
goto
fail
;
n
+=
PyUnicode_GET_SIZE
(
str
);
n
+=
PyUnicode_GET_SIZE
(
str
);
...
@@ -987,7 +987,7 @@ PyObject *PyUnicode_FromOrdinal(int ordinal)
...
@@ -987,7 +987,7 @@ PyObject *PyUnicode_FromOrdinal(int ordinal)
PyObject
*
PyUnicode_FromObject
(
register
PyObject
*
obj
)
PyObject
*
PyUnicode_FromObject
(
register
PyObject
*
obj
)
{
{
/* XXX Perhaps we should make this API an alias of
/* XXX Perhaps we should make this API an alias of
PyObject_
Unicode
() instead ?! */
PyObject_
Str
() instead ?! */
if
(
PyUnicode_CheckExact
(
obj
))
{
if
(
PyUnicode_CheckExact
(
obj
))
{
Py_INCREF
(
obj
);
Py_INCREF
(
obj
);
return
obj
;
return
obj
;
...
@@ -8671,7 +8671,7 @@ PyObject *PyUnicode_Format(PyObject *format,
...
@@ -8671,7 +8671,7 @@ PyObject *PyUnicode_Format(PyObject *format,
else
{
else
{
PyObject
*
unicode
;
PyObject
*
unicode
;
if
(
c
==
's'
)
if
(
c
==
's'
)
temp
=
PyObject_
Unicode
(
v
);
temp
=
PyObject_
Str
(
v
);
else
else
temp
=
PyObject_Repr
(
v
);
temp
=
PyObject_Repr
(
v
);
if
(
temp
==
NULL
)
if
(
temp
==
NULL
)
...
@@ -8889,7 +8889,7 @@ unicode_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
...
@@ -8889,7 +8889,7 @@ unicode_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if
(
x
==
NULL
)
if
(
x
==
NULL
)
return
(
PyObject
*
)
_PyUnicode_New
(
0
);
return
(
PyObject
*
)
_PyUnicode_New
(
0
);
if
(
encoding
==
NULL
&&
errors
==
NULL
)
if
(
encoding
==
NULL
&&
errors
==
NULL
)
return
PyObject_
Unicode
(
x
);
return
PyObject_
Str
(
x
);
else
else
return
PyUnicode_FromEncodedObject
(
x
,
encoding
,
errors
);
return
PyUnicode_FromEncodedObject
(
x
,
encoding
,
errors
);
}
}
...
...
Python/pythonrun.c
View file @
519a042c
...
@@ -911,7 +911,7 @@ PyRun_InteractiveOneFlags(FILE *fp, const char *filename, PyCompilerFlags *flags
...
@@ -911,7 +911,7 @@ PyRun_InteractiveOneFlags(FILE *fp, const char *filename, PyCompilerFlags *flags
}
}
v
=
PySys_GetObject
(
"ps1"
);
v
=
PySys_GetObject
(
"ps1"
);
if
(
v
!=
NULL
)
{
if
(
v
!=
NULL
)
{
v
=
PyObject_
Unicode
(
v
);
v
=
PyObject_
Str
(
v
);
if
(
v
==
NULL
)
if
(
v
==
NULL
)
PyErr_Clear
();
PyErr_Clear
();
else
if
(
PyUnicode_Check
(
v
))
else
if
(
PyUnicode_Check
(
v
))
...
@@ -919,7 +919,7 @@ PyRun_InteractiveOneFlags(FILE *fp, const char *filename, PyCompilerFlags *flags
...
@@ -919,7 +919,7 @@ PyRun_InteractiveOneFlags(FILE *fp, const char *filename, PyCompilerFlags *flags
}
}
w
=
PySys_GetObject
(
"ps2"
);
w
=
PySys_GetObject
(
"ps2"
);
if
(
w
!=
NULL
)
{
if
(
w
!=
NULL
)
{
w
=
PyObject_
Unicode
(
w
);
w
=
PyObject_
Str
(
w
);
if
(
w
==
NULL
)
if
(
w
==
NULL
)
PyErr_Clear
();
PyErr_Clear
();
else
if
(
PyUnicode_Check
(
w
))
else
if
(
PyUnicode_Check
(
w
))
...
@@ -1373,7 +1373,7 @@ PyErr_Display(PyObject *exception, PyObject *value, PyObject *tb)
...
@@ -1373,7 +1373,7 @@ PyErr_Display(PyObject *exception, PyObject *value, PyObject *tb)
else
else
err
=
PyFile_WriteObject
(
exception
,
f
,
Py_PRINT_RAW
);
err
=
PyFile_WriteObject
(
exception
,
f
,
Py_PRINT_RAW
);
if
(
err
==
0
&&
(
value
!=
Py_None
))
{
if
(
err
==
0
&&
(
value
!=
Py_None
))
{
PyObject
*
s
=
PyObject_
Unicode
(
value
);
PyObject
*
s
=
PyObject_
Str
(
value
);
/* only print colon if the str() of the
/* only print colon if the str() of the
object is not the empty string
object is not the empty string
*/
*/
...
@@ -1687,7 +1687,7 @@ err_input(perrdetail *err)
...
@@ -1687,7 +1687,7 @@ err_input(perrdetail *err)
PyObject
*
type
,
*
value
,
*
tb
;
PyObject
*
type
,
*
value
,
*
tb
;
PyErr_Fetch
(
&
type
,
&
value
,
&
tb
);
PyErr_Fetch
(
&
type
,
&
value
,
&
tb
);
if
(
value
!=
NULL
)
{
if
(
value
!=
NULL
)
{
u
=
PyObject_
Unicode
(
value
);
u
=
PyObject_
Str
(
value
);
if
(
u
!=
NULL
)
{
if
(
u
!=
NULL
)
{
msg
=
PyUnicode_AsString
(
u
);
msg
=
PyUnicode_AsString
(
u
);
}
}
...
...
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