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
864741b2
Commit
864741b2
authored
Nov 06, 2011
by
Amaury Forgeot d'Arc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #13350: Replace most usages of PyUnicode_Format by PyUnicode_FromFormat.
parent
08ad2fbc
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
13 additions
and
107 deletions
+13
-107
Doc/includes/noddy2.c
Doc/includes/noddy2.c
+1
-17
Doc/includes/noddy3.c
Doc/includes/noddy3.c
+1
-17
Doc/includes/noddy4.c
Doc/includes/noddy4.c
+1
-17
Misc/NEWS
Misc/NEWS
+3
-0
Modules/_ctypes/_ctypes.c
Modules/_ctypes/_ctypes.c
+3
-21
Modules/_sqlite/cache.c
Modules/_sqlite/cache.c
+2
-19
Objects/listobject.c
Objects/listobject.c
+2
-16
No files found.
Doc/includes/noddy2.c
View file @
864741b2
...
...
@@ -84,15 +84,6 @@ static PyMemberDef Noddy_members[] = {
static
PyObject
*
Noddy_name
(
Noddy
*
self
)
{
static
PyObject
*
format
=
NULL
;
PyObject
*
args
,
*
result
;
if
(
format
==
NULL
)
{
format
=
PyUnicode_FromString
(
"%s %s"
);
if
(
format
==
NULL
)
return
NULL
;
}
if
(
self
->
first
==
NULL
)
{
PyErr_SetString
(
PyExc_AttributeError
,
"first"
);
return
NULL
;
...
...
@@ -103,14 +94,7 @@ Noddy_name(Noddy* self)
return
NULL
;
}
args
=
Py_BuildValue
(
"OO"
,
self
->
first
,
self
->
last
);
if
(
args
==
NULL
)
return
NULL
;
result
=
PyUnicode_Format
(
format
,
args
);
Py_DECREF
(
args
);
return
result
;
return
PyUnicode_FromFormat
(
"%S %S"
,
self
->
first
,
self
->
last
);
}
static
PyMethodDef
Noddy_methods
[]
=
{
...
...
Doc/includes/noddy3.c
View file @
864741b2
...
...
@@ -147,23 +147,7 @@ static PyGetSetDef Noddy_getseters[] = {
static
PyObject
*
Noddy_name
(
Noddy
*
self
)
{
static
PyObject
*
format
=
NULL
;
PyObject
*
args
,
*
result
;
if
(
format
==
NULL
)
{
format
=
PyUnicode_FromString
(
"%s %s"
);
if
(
format
==
NULL
)
return
NULL
;
}
args
=
Py_BuildValue
(
"OO"
,
self
->
first
,
self
->
last
);
if
(
args
==
NULL
)
return
NULL
;
result
=
PyUnicode_Format
(
format
,
args
);
Py_DECREF
(
args
);
return
result
;
return
PyUnicode_FromFormat
(
"%S %S"
,
self
->
first
,
self
->
last
);
}
static
PyMethodDef
Noddy_methods
[]
=
{
...
...
Doc/includes/noddy4.c
View file @
864741b2
...
...
@@ -118,15 +118,6 @@ static PyMemberDef Noddy_members[] = {
static
PyObject
*
Noddy_name
(
Noddy
*
self
)
{
static
PyObject
*
format
=
NULL
;
PyObject
*
args
,
*
result
;
if
(
format
==
NULL
)
{
format
=
PyUnicode_FromString
(
"%s %s"
);
if
(
format
==
NULL
)
return
NULL
;
}
if
(
self
->
first
==
NULL
)
{
PyErr_SetString
(
PyExc_AttributeError
,
"first"
);
return
NULL
;
...
...
@@ -137,14 +128,7 @@ Noddy_name(Noddy* self)
return
NULL
;
}
args
=
Py_BuildValue
(
"OO"
,
self
->
first
,
self
->
last
);
if
(
args
==
NULL
)
return
NULL
;
result
=
PyUnicode_Format
(
format
,
args
);
Py_DECREF
(
args
);
return
result
;
return
PyUnicode_FromFormat
(
"%S %S"
,
self
->
first
,
self
->
last
);
}
static
PyMethodDef
Noddy_methods
[]
=
{
...
...
Misc/NEWS
View file @
864741b2
...
...
@@ -10,6 +10,9 @@ What's New in Python 3.3 Alpha 1?
Core and Builtins
-----------------
- Issue #13350: Simplify some C code by replacing most usages of
PyUnicode_Format by PyUnicode_FromFormat.
- Issue #13342: input() used to ignore sys.stdin'
s
and
sys
.
stdout
's unicode
error handler in interactive mode (when calling into PyOS_Readline()).
...
...
Modules/_ctypes/_ctypes.c
View file @
864741b2
...
...
@@ -4599,38 +4599,20 @@ static PyNumberMethods Simple_as_number = {
static
PyObject
*
Simple_repr
(
CDataObject
*
self
)
{
PyObject
*
val
,
*
name
,
*
args
,
*
result
;
static
PyObject
*
format
;
PyObject
*
val
,
*
result
;
if
(
Py_TYPE
(
self
)
->
tp_base
!=
&
Simple_Type
)
{
return
PyUnicode_FromFormat
(
"<%s object at %p>"
,
Py_TYPE
(
self
)
->
tp_name
,
self
);
}
if
(
format
==
NULL
)
{
format
=
PyUnicode_InternFromString
(
"%s(%r)"
);
if
(
format
==
NULL
)
return
NULL
;
}
val
=
Simple_get_value
(
self
);
if
(
val
==
NULL
)
return
NULL
;
name
=
PyUnicode_FromString
(
Py_TYPE
(
self
)
->
tp_name
);
if
(
name
==
NULL
)
{
Py_DECREF
(
val
);
return
NULL
;
}
args
=
PyTuple_Pack
(
2
,
name
,
val
);
Py_DECREF
(
name
);
result
=
PyUnicode_FromFormat
(
"%s(%R)"
,
Py_TYPE
(
self
)
->
tp_name
,
val
);
Py_DECREF
(
val
);
if
(
args
==
NULL
)
return
NULL
;
result
=
PyUnicode_Format
(
format
,
args
);
Py_DECREF
(
args
);
return
result
;
}
...
...
Modules/_sqlite/cache.c
View file @
864741b2
...
...
@@ -217,8 +217,6 @@ PyObject* pysqlite_cache_display(pysqlite_Cache* self, PyObject* args)
pysqlite_Node
*
ptr
;
PyObject
*
prevkey
;
PyObject
*
nextkey
;
PyObject
*
fmt_args
;
PyObject
*
template
;
PyObject
*
display_str
;
ptr
=
self
->
first
;
...
...
@@ -229,36 +227,21 @@ PyObject* pysqlite_cache_display(pysqlite_Cache* self, PyObject* args)
}
else
{
prevkey
=
Py_None
;
}
Py_INCREF
(
prevkey
);
if
(
ptr
->
next
)
{
nextkey
=
ptr
->
next
->
key
;
}
else
{
nextkey
=
Py_None
;
}
Py_INCREF
(
nextkey
);
fmt_args
=
Py_BuildValue
(
"OOO"
,
prevkey
,
ptr
->
key
,
nextkey
);
if
(
!
fmt_args
)
{
return
NULL
;
}
template
=
PyUnicode_FromString
(
"%s <- %s ->%s
\n
"
);
if
(
!
template
)
{
Py_DECREF
(
fmt_args
);
return
NULL
;
}
display_str
=
PyUnicode_Format
(
template
,
fmt_args
);
Py_DECREF
(
template
);
Py_DECREF
(
fmt_args
);
display_str
=
PyUnicode_FromFormat
(
"%S <- %S -> %S
\n
"
,
prevkey
,
ptr
->
key
,
nextkey
);
if
(
!
display_str
)
{
return
NULL
;
}
PyObject_Print
(
display_str
,
stdout
,
Py_PRINT_RAW
);
Py_DECREF
(
display_str
);
Py_DECREF
(
prevkey
);
Py_DECREF
(
nextkey
);
ptr
=
ptr
->
next
;
}
...
...
Objects/listobject.c
View file @
864741b2
...
...
@@ -2121,9 +2121,8 @@ static PyObject *
listindex
(
PyListObject
*
self
,
PyObject
*
args
)
{
Py_ssize_t
i
,
start
=
0
,
stop
=
Py_SIZE
(
self
);
PyObject
*
v
,
*
format_tuple
,
*
err_string
;
PyObject
*
v
;
PyObject
*
start_obj
=
NULL
,
*
stop_obj
=
NULL
;
static
PyObject
*
err_format
=
NULL
;
if
(
!
PyArg_ParseTuple
(
args
,
"O|OO:index"
,
&
v
,
&
start_obj
,
&
stop_obj
))
return
NULL
;
...
...
@@ -2153,20 +2152,7 @@ listindex(PyListObject *self, PyObject *args)
else
if
(
cmp
<
0
)
return
NULL
;
}
if
(
err_format
==
NULL
)
{
err_format
=
PyUnicode_FromString
(
"%r is not in list"
);
if
(
err_format
==
NULL
)
return
NULL
;
}
format_tuple
=
PyTuple_Pack
(
1
,
v
);
if
(
format_tuple
==
NULL
)
return
NULL
;
err_string
=
PyUnicode_Format
(
err_format
,
format_tuple
);
Py_DECREF
(
format_tuple
);
if
(
err_string
==
NULL
)
return
NULL
;
PyErr_SetObject
(
PyExc_ValueError
,
err_string
);
Py_DECREF
(
err_string
);
PyErr_Format
(
PyExc_ValueError
,
"%R is not in list"
,
v
);
return
NULL
;
}
...
...
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