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
e3eb1f2b
Commit
e3eb1f2b
authored
Aug 16, 2001
by
Martin v. Löwis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Patch #427190: Implement and use METH_NOARGS and METH_O.
parent
c3542210
Changes
17
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
430 additions
and
552 deletions
+430
-552
Doc/api/api.tex
Doc/api/api.tex
+62
-0
Misc/NEWS
Misc/NEWS
+6
-0
Objects/complexobject.c
Objects/complexobject.c
+2
-4
Objects/descrobject.c
Objects/descrobject.c
+10
-22
Objects/dictobject.c
Objects/dictobject.c
+25
-50
Objects/fileobject.c
Objects/fileobject.c
+20
-33
Objects/iterobject.c
Objects/iterobject.c
+2
-2
Objects/listobject.c
Objects/listobject.c
+19
-38
Objects/methodobject.c
Objects/methodobject.c
+26
-7
Objects/rangeobject.c
Objects/rangeobject.c
+1
-4
Objects/stringobject.c
Objects/stringobject.c
+56
-103
Objects/typeobject.c
Objects/typeobject.c
+2
-4
Objects/unicodeobject.c
Objects/unicodeobject.c
+60
-116
Python/bltinmodule.c
Python/bltinmodule.c
+59
-100
Python/ceval.c
Python/ceval.c
+50
-23
Python/sysmodule.c
Python/sysmodule.c
+29
-45
configure
configure
+1
-1
No files found.
Doc/api/api.tex
View file @
e3eb1f2b
...
@@ -5257,6 +5257,68 @@ structure has four fields:
...
@@ -5257,6 +5257,68 @@ structure has four fields:
\end{tableiii}
\end{tableiii}
\end{ctypedesc}
\end{ctypedesc}
The
\var
{
ml
_
meth
}
is a C function pointer. The functions may be of
different types, but they always return
\ctype
{
PyObject*
}
. If the
function is not of the
\ctype
{
PyCFunction
}
, the compiler will require
a cast in the method table. Even though
\ctype
{
PyCFunction
}
defines
the first parameter as
\ctype
{
PyObject*
}
, it is common that the method
implementation uses a the specific C type of the
\var
{
self
}
object.
The flags can have the following values. Only METH
_
VARARGS and
METH
_
KEYWORDS can be combined; the others can't.
\begin{datadesc}
{
METH
_
VARARGS
}
This is the typical calling convention, where the methods have the
type
\ctype
{
PyMethodDef
}
. The function expects two
\ctype
{
PyObject*
}
.
The first one is the
\var
{
self
}
object for methods; for module
functions, it has the value given to
\cfunction
{
PyInitModule4
}
(or
\NULL
{}
if
\cfunction
{
PyInitModule
}
was used). The second parameter
(often called
\var
{
args
}
) is a tuple object representing all
arguments. This parameter is typically processed using
\cfunction
{
PyArg
_
ParseTuple
}
.
\end{datadesc}
\begin{datadesc}
{
METH
_
KEYWORDS
}
Methods with these flags must be of type
\ctype
{
PyCFunctionWithKeywords
}
. The function expects three
parameters:
\var
{
self
}
,
\var
{
args
}
, and a dictionary of all the keyword
arguments. The flag is typically combined with METH
_
VARARGS, and the
parameters are typically processed using
\cfunction
{
PyArg
_
ParseTupleAndKeywords
}
.
\end{datadesc}
\begin{datadesc}
{
METH
_
NOARGS
}
Methods without parameters don't need to check whether arguments are
given if they are listed with the
\code
{
METH
_
NOARGS
}
flag. They need
to be of type
\ctype
{
PyNoArgsFunction
}
, i.e. they expect a single
\var
{
self
}
parameter.
\end{datadesc}
\begin{datadesc}
{
METH
_
O
}
Methods with a single object argument can be listed with the
\code
{
METH
_
O
}
flag, instead of invoking
\cfunction
{
PyArg
_
ParseTuple
}
with a
\code
{
``O''
}
argument. They have the type
\ctype
{
PyCFunction
}
,
with the
\var
{
self
}
parameter, and a
\ctype
{
PyObject*
}
parameter
representing the single argument.
\end{datadesc}
\begin{datadesc}
{
METH
_
OLDARGS
}
This calling convention is deprecated. The method must be of type
\ctype
{
PyCFunction
}
. The second argument is
\NULL
{}
if no arguments
are given, a single object if exactly one argument is given, and a
tuple of objects if more than one argument is given.
\end{datadesc}
\begin{cfuncdesc}
{
PyObject*
}{
Py
_
FindMethod
}{
PyMethodDef[] table,
\begin{cfuncdesc}
{
PyObject*
}{
Py
_
FindMethod
}{
PyMethodDef[] table,
PyObject *ob, char *name
}
PyObject *ob, char *name
}
Return a bound method object for an extension type implemented in C.
Return a bound method object for an extension type implemented in C.
...
...
Misc/NEWS
View file @
e3eb1f2b
...
@@ -90,6 +90,12 @@ Core
...
@@ -90,6 +90,12 @@ Core
(These warnings currently don't conform to the warnings framework of
(These warnings currently don't conform to the warnings framework of
PEP 230; we intend to fix this in 2.2a2.)
PEP 230; we intend to fix this in 2.2a2.)
- Two new flags METH_NOARGS and METH_O are available in method definition
tables to simplify implementation of methods with no arguments and a
single untyped argument. Calling such methods is more efficient than
calling corresponding METH_VARARGS methods. METH_OLDARGS is now
deprecated.
- The UTF-16 codec was modified to be more RFC compliant. It will now
- The UTF-16 codec was modified to be more RFC compliant. It will now
only remove BOM characters at the start of the string and then
only remove BOM characters at the start of the string and then
only if running in native mode (UTF-16-LE and -BE won't remove a
only if running in native mode (UTF-16-LE and -BE won't remove a
...
...
Objects/complexobject.c
View file @
e3eb1f2b
...
@@ -580,18 +580,16 @@ complex_float(PyObject *v)
...
@@ -580,18 +580,16 @@ complex_float(PyObject *v)
}
}
static
PyObject
*
static
PyObject
*
complex_conjugate
(
PyObject
*
self
,
PyObject
*
args
)
complex_conjugate
(
PyObject
*
self
)
{
{
Py_complex
c
;
Py_complex
c
;
if
(
!
PyArg_ParseTuple
(
args
,
":conjugate"
))
return
NULL
;
c
=
((
PyComplexObject
*
)
self
)
->
cval
;
c
=
((
PyComplexObject
*
)
self
)
->
cval
;
c
.
imag
=
-
c
.
imag
;
c
.
imag
=
-
c
.
imag
;
return
PyComplex_FromCComplex
(
c
);
return
PyComplex_FromCComplex
(
c
);
}
}
static
PyMethodDef
complex_methods
[]
=
{
static
PyMethodDef
complex_methods
[]
=
{
{
"conjugate"
,
complex_conjugate
,
1
},
{
"conjugate"
,
(
PyCFunction
)
complex_conjugate
,
METH_NOARGS
},
{
NULL
,
NULL
}
/* sentinel */
{
NULL
,
NULL
}
/* sentinel */
};
};
...
...
Objects/descrobject.c
View file @
e3eb1f2b
...
@@ -601,12 +601,8 @@ static PySequenceMethods proxy_as_sequence = {
...
@@ -601,12 +601,8 @@ static PySequenceMethods proxy_as_sequence = {
};
};
static
PyObject
*
static
PyObject
*
proxy_has_key
(
proxyobject
*
pp
,
PyObject
*
args
)
proxy_has_key
(
proxyobject
*
pp
,
PyObject
*
key
)
{
{
PyObject
*
key
;
if
(
!
PyArg_ParseTuple
(
args
,
"O:has_key"
,
&
key
))
return
NULL
;
return
PyInt_FromLong
(
PySequence_Contains
(
pp
->
dict
,
key
));
return
PyInt_FromLong
(
PySequence_Contains
(
pp
->
dict
,
key
));
}
}
...
@@ -621,44 +617,36 @@ proxy_get(proxyobject *pp, PyObject *args)
...
@@ -621,44 +617,36 @@ proxy_get(proxyobject *pp, PyObject *args)
}
}
static
PyObject
*
static
PyObject
*
proxy_keys
(
proxyobject
*
pp
,
PyObject
*
args
)
proxy_keys
(
proxyobject
*
pp
)
{
{
if
(
!
PyArg_ParseTuple
(
args
,
":keys"
))
return
NULL
;
return
PyMapping_Keys
(
pp
->
dict
);
return
PyMapping_Keys
(
pp
->
dict
);
}
}
static
PyObject
*
static
PyObject
*
proxy_values
(
proxyobject
*
pp
,
PyObject
*
args
)
proxy_values
(
proxyobject
*
pp
)
{
{
if
(
!
PyArg_ParseTuple
(
args
,
":values"
))
return
NULL
;
return
PyMapping_Values
(
pp
->
dict
);
return
PyMapping_Values
(
pp
->
dict
);
}
}
static
PyObject
*
static
PyObject
*
proxy_items
(
proxyobject
*
pp
,
PyObject
*
args
)
proxy_items
(
proxyobject
*
pp
)
{
{
if
(
!
PyArg_ParseTuple
(
args
,
":items"
))
return
NULL
;
return
PyMapping_Items
(
pp
->
dict
);
return
PyMapping_Items
(
pp
->
dict
);
}
}
static
PyObject
*
static
PyObject
*
proxy_copy
(
proxyobject
*
pp
,
PyObject
*
args
)
proxy_copy
(
proxyobject
*
pp
)
{
{
if
(
!
PyArg_ParseTuple
(
args
,
":copy"
))
return
NULL
;
return
PyObject_CallMethod
(
pp
->
dict
,
"copy"
,
NULL
);
return
PyObject_CallMethod
(
pp
->
dict
,
"copy"
,
NULL
);
}
}
static
PyMethodDef
proxy_methods
[]
=
{
static
PyMethodDef
proxy_methods
[]
=
{
{
"has_key"
,
(
PyCFunction
)
proxy_has_key
,
METH_
VARARGS
,
"XXX"
},
{
"has_key"
,
(
PyCFunction
)
proxy_has_key
,
METH_
O
,
"XXX"
},
{
"get"
,
(
PyCFunction
)
proxy_get
,
METH_VARARGS
,
"XXX"
},
{
"get"
,
(
PyCFunction
)
proxy_get
,
METH_VARARGS
,
"XXX"
},
{
"keys"
,
(
PyCFunction
)
proxy_keys
,
METH_
VAR
ARGS
,
"XXX"
},
{
"keys"
,
(
PyCFunction
)
proxy_keys
,
METH_
NO
ARGS
,
"XXX"
},
{
"values"
,
(
PyCFunction
)
proxy_values
,
METH_
VAR
ARGS
,
"XXX"
},
{
"values"
,
(
PyCFunction
)
proxy_values
,
METH_
NO
ARGS
,
"XXX"
},
{
"items"
,
(
PyCFunction
)
proxy_items
,
METH_
VAR
ARGS
,
"XXX"
},
{
"items"
,
(
PyCFunction
)
proxy_items
,
METH_
NO
ARGS
,
"XXX"
},
{
"copy"
,
(
PyCFunction
)
proxy_copy
,
METH_
VAR
ARGS
,
"XXX"
},
{
"copy"
,
(
PyCFunction
)
proxy_copy
,
METH_
NO
ARGS
,
"XXX"
},
{
0
}
{
0
}
};
};
...
...
Objects/dictobject.c
View file @
e3eb1f2b
...
@@ -875,13 +875,11 @@ static PyMappingMethods dict_as_mapping = {
...
@@ -875,13 +875,11 @@ static PyMappingMethods dict_as_mapping = {
};
};
static
PyObject
*
static
PyObject
*
dict_keys
(
register
dictobject
*
mp
,
PyObject
*
args
)
dict_keys
(
register
dictobject
*
mp
)
{
{
register
PyObject
*
v
;
register
PyObject
*
v
;
register
int
i
,
j
,
n
;
register
int
i
,
j
,
n
;
if
(
!
PyArg_NoArgs
(
args
))
return
NULL
;
again:
again:
n
=
mp
->
ma_used
;
n
=
mp
->
ma_used
;
v
=
PyList_New
(
n
);
v
=
PyList_New
(
n
);
...
@@ -906,13 +904,11 @@ dict_keys(register dictobject *mp, PyObject *args)
...
@@ -906,13 +904,11 @@ dict_keys(register dictobject *mp, PyObject *args)
}
}
static
PyObject
*
static
PyObject
*
dict_values
(
register
dictobject
*
mp
,
PyObject
*
args
)
dict_values
(
register
dictobject
*
mp
)
{
{
register
PyObject
*
v
;
register
PyObject
*
v
;
register
int
i
,
j
,
n
;
register
int
i
,
j
,
n
;
if
(
!
PyArg_NoArgs
(
args
))
return
NULL
;
again:
again:
n
=
mp
->
ma_used
;
n
=
mp
->
ma_used
;
v
=
PyList_New
(
n
);
v
=
PyList_New
(
n
);
...
@@ -937,14 +933,12 @@ dict_values(register dictobject *mp, PyObject *args)
...
@@ -937,14 +933,12 @@ dict_values(register dictobject *mp, PyObject *args)
}
}
static
PyObject
*
static
PyObject
*
dict_items
(
register
dictobject
*
mp
,
PyObject
*
args
)
dict_items
(
register
dictobject
*
mp
)
{
{
register
PyObject
*
v
;
register
PyObject
*
v
;
register
int
i
,
j
,
n
;
register
int
i
,
j
,
n
;
PyObject
*
item
,
*
key
,
*
value
;
PyObject
*
item
,
*
key
,
*
value
;
if
(
!
PyArg_NoArgs
(
args
))
return
NULL
;
/* Preallocate the list of tuples, to avoid allocations during
/* Preallocate the list of tuples, to avoid allocations during
* the loop over the items, which could trigger GC, which
* the loop over the items, which could trigger GC, which
* could resize the dict. :-(
* could resize the dict. :-(
...
@@ -987,12 +981,8 @@ dict_items(register dictobject *mp, PyObject *args)
...
@@ -987,12 +981,8 @@ dict_items(register dictobject *mp, PyObject *args)
}
}
static
PyObject
*
static
PyObject
*
dict_update
(
PyObject
*
mp
,
PyObject
*
args
)
dict_update
(
PyObject
*
mp
,
PyObject
*
other
)
{
{
PyObject
*
other
;
if
(
!
PyArg_ParseTuple
(
args
,
"O:update"
,
&
other
))
return
NULL
;
if
(
PyDict_Update
(
mp
,
other
)
<
0
)
if
(
PyDict_Update
(
mp
,
other
)
<
0
)
return
NULL
;
return
NULL
;
Py_INCREF
(
Py_None
);
Py_INCREF
(
Py_None
);
...
@@ -1099,10 +1089,8 @@ PyDict_Merge(PyObject *a, PyObject *b, int override)
...
@@ -1099,10 +1089,8 @@ PyDict_Merge(PyObject *a, PyObject *b, int override)
}
}
static
PyObject
*
static
PyObject
*
dict_copy
(
register
dictobject
*
mp
,
PyObject
*
args
)
dict_copy
(
register
dictobject
*
mp
)
{
{
if
(
!
PyArg_Parse
(
args
,
""
))
return
NULL
;
return
PyDict_Copy
((
PyObject
*
)
mp
);
return
PyDict_Copy
((
PyObject
*
)
mp
);
}
}
...
@@ -1155,7 +1143,7 @@ PyDict_Keys(PyObject *mp)
...
@@ -1155,7 +1143,7 @@ PyDict_Keys(PyObject *mp)
PyErr_BadInternalCall
();
PyErr_BadInternalCall
();
return
NULL
;
return
NULL
;
}
}
return
dict_keys
((
dictobject
*
)
mp
,
(
PyObject
*
)
NULL
);
return
dict_keys
((
dictobject
*
)
mp
);
}
}
PyObject
*
PyObject
*
...
@@ -1165,7 +1153,7 @@ PyDict_Values(PyObject *mp)
...
@@ -1165,7 +1153,7 @@ PyDict_Values(PyObject *mp)
PyErr_BadInternalCall
();
PyErr_BadInternalCall
();
return
NULL
;
return
NULL
;
}
}
return
dict_values
((
dictobject
*
)
mp
,
(
PyObject
*
)
NULL
);
return
dict_values
((
dictobject
*
)
mp
);
}
}
PyObject
*
PyObject
*
...
@@ -1175,7 +1163,7 @@ PyDict_Items(PyObject *mp)
...
@@ -1175,7 +1163,7 @@ PyDict_Items(PyObject *mp)
PyErr_BadInternalCall
();
PyErr_BadInternalCall
();
return
NULL
;
return
NULL
;
}
}
return
dict_items
((
dictobject
*
)
mp
,
(
PyObject
*
)
NULL
);
return
dict_items
((
dictobject
*
)
mp
);
}
}
/* Subroutine which returns the smallest key in a for which b's value
/* Subroutine which returns the smallest key in a for which b's value
...
@@ -1366,13 +1354,10 @@ dict_richcompare(PyObject *v, PyObject *w, int op)
...
@@ -1366,13 +1354,10 @@ dict_richcompare(PyObject *v, PyObject *w, int op)
}
}
static
PyObject
*
static
PyObject
*
dict_has_key
(
register
dictobject
*
mp
,
PyObject
*
args
)
dict_has_key
(
register
dictobject
*
mp
,
PyObject
*
key
)
{
{
PyObject
*
key
;
long
hash
;
long
hash
;
register
long
ok
;
register
long
ok
;
if
(
!
PyArg_ParseTuple
(
args
,
"O:has_key"
,
&
key
))
return
NULL
;
#ifdef CACHE_HASH
#ifdef CACHE_HASH
if
(
!
PyString_Check
(
key
)
||
if
(
!
PyString_Check
(
key
)
||
(
hash
=
((
PyStringObject
*
)
key
)
->
ob_shash
)
==
-
1
)
(
hash
=
((
PyStringObject
*
)
key
)
->
ob_shash
)
==
-
1
)
...
@@ -1447,24 +1432,20 @@ dict_setdefault(register dictobject *mp, PyObject *args)
...
@@ -1447,24 +1432,20 @@ dict_setdefault(register dictobject *mp, PyObject *args)
static
PyObject
*
static
PyObject
*
dict_clear
(
register
dictobject
*
mp
,
PyObject
*
args
)
dict_clear
(
register
dictobject
*
mp
)
{
{
if
(
!
PyArg_NoArgs
(
args
))
return
NULL
;
PyDict_Clear
((
PyObject
*
)
mp
);
PyDict_Clear
((
PyObject
*
)
mp
);
Py_INCREF
(
Py_None
);
Py_INCREF
(
Py_None
);
return
Py_None
;
return
Py_None
;
}
}
static
PyObject
*
static
PyObject
*
dict_popitem
(
dictobject
*
mp
,
PyObject
*
args
)
dict_popitem
(
dictobject
*
mp
)
{
{
int
i
=
0
;
int
i
=
0
;
dictentry
*
ep
;
dictentry
*
ep
;
PyObject
*
res
;
PyObject
*
res
;
if
(
!
PyArg_NoArgs
(
args
))
return
NULL
;
/* Allocate the result tuple before checking the size. Believe it
/* Allocate the result tuple before checking the size. Believe it
* or not, this allocation could trigger a garbage collection which
* or not, this allocation could trigger a garbage collection which
* could empty the dict, so if we checked the size first and that
* could empty the dict, so if we checked the size first and that
...
@@ -1573,26 +1554,20 @@ select_item(PyObject *key, PyObject *value)
...
@@ -1573,26 +1554,20 @@ select_item(PyObject *key, PyObject *value)
}
}
static
PyObject
*
static
PyObject
*
dict_iterkeys
(
dictobject
*
dict
,
PyObject
*
args
)
dict_iterkeys
(
dictobject
*
dict
)
{
{
if
(
!
PyArg_ParseTuple
(
args
,
""
))
return
NULL
;
return
dictiter_new
(
dict
,
select_key
);
return
dictiter_new
(
dict
,
select_key
);
}
}
static
PyObject
*
static
PyObject
*
dict_itervalues
(
dictobject
*
dict
,
PyObject
*
args
)
dict_itervalues
(
dictobject
*
dict
)
{
{
if
(
!
PyArg_ParseTuple
(
args
,
""
))
return
NULL
;
return
dictiter_new
(
dict
,
select_value
);
return
dictiter_new
(
dict
,
select_value
);
}
}
static
PyObject
*
static
PyObject
*
dict_iteritems
(
dictobject
*
dict
,
PyObject
*
args
)
dict_iteritems
(
dictobject
*
dict
)
{
{
if
(
!
PyArg_ParseTuple
(
args
,
""
))
return
NULL
;
return
dictiter_new
(
dict
,
select_item
);
return
dictiter_new
(
dict
,
select_item
);
}
}
...
@@ -1638,31 +1613,31 @@ static char iteritems__doc__[] =
...
@@ -1638,31 +1613,31 @@ static char iteritems__doc__[] =
"D.iteritems() -> an iterator over the (key, value) items of D"
;
"D.iteritems() -> an iterator over the (key, value) items of D"
;
static
PyMethodDef
mapp_methods
[]
=
{
static
PyMethodDef
mapp_methods
[]
=
{
{
"has_key"
,
(
PyCFunction
)
dict_has_key
,
METH_
VARARGS
,
{
"has_key"
,
(
PyCFunction
)
dict_has_key
,
METH_
O
,
has_key__doc__
},
has_key__doc__
},
{
"get"
,
(
PyCFunction
)
dict_get
,
METH_VARARGS
,
{
"get"
,
(
PyCFunction
)
dict_get
,
METH_VARARGS
,
get__doc__
},
get__doc__
},
{
"setdefault"
,
(
PyCFunction
)
dict_setdefault
,
METH_VARARGS
,
{
"setdefault"
,
(
PyCFunction
)
dict_setdefault
,
METH_VARARGS
,
setdefault_doc__
},
setdefault_doc__
},
{
"popitem"
,
(
PyCFunction
)
dict_popitem
,
METH_
OLD
ARGS
,
{
"popitem"
,
(
PyCFunction
)
dict_popitem
,
METH_
NO
ARGS
,
popitem__doc__
},
popitem__doc__
},
{
"keys"
,
(
PyCFunction
)
dict_keys
,
METH_
OLD
ARGS
,
{
"keys"
,
(
PyCFunction
)
dict_keys
,
METH_
NO
ARGS
,
keys__doc__
},
keys__doc__
},
{
"items"
,
(
PyCFunction
)
dict_items
,
METH_
OLD
ARGS
,
{
"items"
,
(
PyCFunction
)
dict_items
,
METH_
NO
ARGS
,
items__doc__
},
items__doc__
},
{
"values"
,
(
PyCFunction
)
dict_values
,
METH_
OLD
ARGS
,
{
"values"
,
(
PyCFunction
)
dict_values
,
METH_
NO
ARGS
,
values__doc__
},
values__doc__
},
{
"update"
,
(
PyCFunction
)
dict_update
,
METH_
VARARGS
,
{
"update"
,
(
PyCFunction
)
dict_update
,
METH_
O
,
update__doc__
},
update__doc__
},
{
"clear"
,
(
PyCFunction
)
dict_clear
,
METH_
OLD
ARGS
,
{
"clear"
,
(
PyCFunction
)
dict_clear
,
METH_
NO
ARGS
,
clear__doc__
},
clear__doc__
},
{
"copy"
,
(
PyCFunction
)
dict_copy
,
METH_
OLD
ARGS
,
{
"copy"
,
(
PyCFunction
)
dict_copy
,
METH_
NO
ARGS
,
copy__doc__
},
copy__doc__
},
{
"iterkeys"
,
(
PyCFunction
)
dict_iterkeys
,
METH_
VAR
ARGS
,
{
"iterkeys"
,
(
PyCFunction
)
dict_iterkeys
,
METH_
NO
ARGS
,
iterkeys__doc__
},
iterkeys__doc__
},
{
"itervalues"
,
(
PyCFunction
)
dict_itervalues
,
METH_
VAR
ARGS
,
{
"itervalues"
,
(
PyCFunction
)
dict_itervalues
,
METH_
NO
ARGS
,
itervalues__doc__
},
itervalues__doc__
},
{
"iteritems"
,
(
PyCFunction
)
dict_iteritems
,
METH_
VAR
ARGS
,
{
"iteritems"
,
(
PyCFunction
)
dict_iteritems
,
METH_
NO
ARGS
,
iteritems__doc__
},
iteritems__doc__
},
{
NULL
,
NULL
}
/* sentinel */
{
NULL
,
NULL
}
/* sentinel */
};
};
...
...
Objects/fileobject.c
View file @
e3eb1f2b
...
@@ -189,11 +189,9 @@ file_repr(PyFileObject *f)
...
@@ -189,11 +189,9 @@ file_repr(PyFileObject *f)
}
}
static
PyObject
*
static
PyObject
*
file_close
(
PyFileObject
*
f
,
PyObject
*
args
)
file_close
(
PyFileObject
*
f
)
{
{
int
sts
=
0
;
int
sts
=
0
;
if
(
!
PyArg_NoArgs
(
args
))
return
NULL
;
if
(
f
->
f_fp
!=
NULL
)
{
if
(
f
->
f_fp
!=
NULL
)
{
if
(
f
->
f_close
!=
NULL
)
{
if
(
f
->
f_close
!=
NULL
)
{
Py_BEGIN_ALLOW_THREADS
Py_BEGIN_ALLOW_THREADS
...
@@ -386,14 +384,12 @@ onioerror:
...
@@ -386,14 +384,12 @@ onioerror:
#endif
/* HAVE_FTRUNCATE */
#endif
/* HAVE_FTRUNCATE */
static
PyObject
*
static
PyObject
*
file_tell
(
PyFileObject
*
f
,
PyObject
*
args
)
file_tell
(
PyFileObject
*
f
)
{
{
Py_off_t
pos
;
Py_off_t
pos
;
if
(
f
->
f_fp
==
NULL
)
if
(
f
->
f_fp
==
NULL
)
return
err_closed
();
return
err_closed
();
if
(
!
PyArg_NoArgs
(
args
))
return
NULL
;
Py_BEGIN_ALLOW_THREADS
Py_BEGIN_ALLOW_THREADS
errno
=
0
;
errno
=
0
;
pos
=
_portable_ftell
(
f
->
f_fp
);
pos
=
_portable_ftell
(
f
->
f_fp
);
...
@@ -411,24 +407,20 @@ file_tell(PyFileObject *f, PyObject *args)
...
@@ -411,24 +407,20 @@ file_tell(PyFileObject *f, PyObject *args)
}
}
static
PyObject
*
static
PyObject
*
file_fileno
(
PyFileObject
*
f
,
PyObject
*
args
)
file_fileno
(
PyFileObject
*
f
)
{
{
if
(
f
->
f_fp
==
NULL
)
if
(
f
->
f_fp
==
NULL
)
return
err_closed
();
return
err_closed
();
if
(
!
PyArg_NoArgs
(
args
))
return
NULL
;
return
PyInt_FromLong
((
long
)
fileno
(
f
->
f_fp
));
return
PyInt_FromLong
((
long
)
fileno
(
f
->
f_fp
));
}
}
static
PyObject
*
static
PyObject
*
file_flush
(
PyFileObject
*
f
,
PyObject
*
args
)
file_flush
(
PyFileObject
*
f
)
{
{
int
res
;
int
res
;
if
(
f
->
f_fp
==
NULL
)
if
(
f
->
f_fp
==
NULL
)
return
err_closed
();
return
err_closed
();
if
(
!
PyArg_NoArgs
(
args
))
return
NULL
;
Py_BEGIN_ALLOW_THREADS
Py_BEGIN_ALLOW_THREADS
errno
=
0
;
errno
=
0
;
res
=
fflush
(
f
->
f_fp
);
res
=
fflush
(
f
->
f_fp
);
...
@@ -443,13 +435,11 @@ file_flush(PyFileObject *f, PyObject *args)
...
@@ -443,13 +435,11 @@ file_flush(PyFileObject *f, PyObject *args)
}
}
static
PyObject
*
static
PyObject
*
file_isatty
(
PyFileObject
*
f
,
PyObject
*
args
)
file_isatty
(
PyFileObject
*
f
)
{
{
long
res
;
long
res
;
if
(
f
->
f_fp
==
NULL
)
if
(
f
->
f_fp
==
NULL
)
return
err_closed
();
return
err_closed
();
if
(
!
PyArg_NoArgs
(
args
))
return
NULL
;
Py_BEGIN_ALLOW_THREADS
Py_BEGIN_ALLOW_THREADS
res
=
isatty
((
int
)
fileno
(
f
->
f_fp
));
res
=
isatty
((
int
)
fileno
(
f
->
f_fp
));
Py_END_ALLOW_THREADS
Py_END_ALLOW_THREADS
...
@@ -968,13 +958,10 @@ file_readline(PyFileObject *f, PyObject *args)
...
@@ -968,13 +958,10 @@ file_readline(PyFileObject *f, PyObject *args)
}
}
static
PyObject
*
static
PyObject
*
file_xreadlines
(
PyFileObject
*
f
,
PyObject
*
args
)
file_xreadlines
(
PyFileObject
*
f
)
{
{
static
PyObject
*
xreadlines_function
=
NULL
;
static
PyObject
*
xreadlines_function
=
NULL
;
if
(
!
PyArg_ParseTuple
(
args
,
":xreadlines"
))
return
NULL
;
if
(
!
xreadlines_function
)
{
if
(
!
xreadlines_function
)
{
PyObject
*
xreadlines_module
=
PyObject
*
xreadlines_module
=
PyImport_ImportModule
(
"xreadlines"
);
PyImport_ImportModule
(
"xreadlines"
);
...
@@ -1248,22 +1235,22 @@ file_writelines(PyFileObject *f, PyObject *args)
...
@@ -1248,22 +1235,22 @@ file_writelines(PyFileObject *f, PyObject *args)
}
}
static
PyMethodDef
file_methods
[]
=
{
static
PyMethodDef
file_methods
[]
=
{
{
"readline"
,
(
PyCFunction
)
file_readline
,
1
},
{
"readline"
,
(
PyCFunction
)
file_readline
,
METH_VARARGS
},
{
"read"
,
(
PyCFunction
)
file_read
,
1
},
{
"read"
,
(
PyCFunction
)
file_read
,
METH_VARARGS
},
{
"write"
,
(
PyCFunction
)
file_write
,
0
},
{
"write"
,
(
PyCFunction
)
file_write
,
METH_OLDARGS
},
{
"fileno"
,
(
PyCFunction
)
file_fileno
,
0
},
{
"fileno"
,
(
PyCFunction
)
file_fileno
,
METH_NOARGS
},
{
"seek"
,
(
PyCFunction
)
file_seek
,
1
},
{
"seek"
,
(
PyCFunction
)
file_seek
,
METH_VARARGS
},
#ifdef HAVE_FTRUNCATE
#ifdef HAVE_FTRUNCATE
{
"truncate"
,
(
PyCFunction
)
file_truncate
,
1
},
{
"truncate"
,
(
PyCFunction
)
file_truncate
,
METH_VARARGS
},
#endif
#endif
{
"tell"
,
(
PyCFunction
)
file_tell
,
0
},
{
"tell"
,
(
PyCFunction
)
file_tell
,
METH_NOARGS
},
{
"readinto"
,
(
PyCFunction
)
file_readinto
,
0
},
{
"readinto"
,
(
PyCFunction
)
file_readinto
,
METH_OLDARGS
},
{
"readlines"
,
(
PyCFunction
)
file_readlines
,
1
},
{
"readlines"
,
(
PyCFunction
)
file_readlines
,
METH_VARARGS
},
{
"xreadlines"
,
(
PyCFunction
)
file_xreadlines
,
1
},
{
"xreadlines"
,
(
PyCFunction
)
file_xreadlines
,
METH_NOARGS
},
{
"writelines"
,
(
PyCFunction
)
file_writelines
,
0
},
{
"writelines"
,
(
PyCFunction
)
file_writelines
,
METH_O
},
{
"flush"
,
(
PyCFunction
)
file_flush
,
0
},
{
"flush"
,
(
PyCFunction
)
file_flush
,
METH_NOARGS
},
{
"close"
,
(
PyCFunction
)
file_close
,
0
},
{
"close"
,
(
PyCFunction
)
file_close
,
METH_NOARGS
},
{
"isatty"
,
(
PyCFunction
)
file_isatty
,
0
},
{
"isatty"
,
(
PyCFunction
)
file_isatty
,
METH_NOARGS
},
{
NULL
,
NULL
}
/* sentinel */
{
NULL
,
NULL
}
/* sentinel */
};
};
...
...
Objects/iterobject.c
View file @
e3eb1f2b
...
@@ -37,7 +37,7 @@ iter_traverse(seqiterobject *it, visitproc visit, void *arg)
...
@@ -37,7 +37,7 @@ iter_traverse(seqiterobject *it, visitproc visit, void *arg)
}
}
static
PyObject
*
static
PyObject
*
iter_next
(
seqiterobject
*
it
,
PyObject
*
args
)
iter_next
(
seqiterobject
*
it
)
{
{
PyObject
*
seq
=
it
->
it_seq
;
PyObject
*
seq
=
it
->
it_seq
;
PyObject
*
result
=
PySequence_GetItem
(
seq
,
it
->
it_index
++
);
PyObject
*
result
=
PySequence_GetItem
(
seq
,
it
->
it_index
++
);
...
@@ -91,7 +91,7 @@ iter_iternext(PyObject *iterator)
...
@@ -91,7 +91,7 @@ iter_iternext(PyObject *iterator)
}
}
static
PyMethodDef
iter_methods
[]
=
{
static
PyMethodDef
iter_methods
[]
=
{
{
"next"
,
(
PyCFunction
)
iter_next
,
METH_
VAR
ARGS
,
{
"next"
,
(
PyCFunction
)
iter_next
,
METH_
NO
ARGS
,
"it.next() -- get the next value, or raise StopIteration"
},
"it.next() -- get the next value, or raise StopIteration"
},
{
NULL
,
NULL
}
/* sentinel */
{
NULL
,
NULL
}
/* sentinel */
};
};
...
...
Objects/listobject.c
View file @
e3eb1f2b
...
@@ -623,11 +623,8 @@ listinsert(PyListObject *self, PyObject *args)
...
@@ -623,11 +623,8 @@ listinsert(PyListObject *self, PyObject *args)
}
}
static
PyObject
*
static
PyObject
*
listappend
(
PyListObject
*
self
,
PyObject
*
args
)
listappend
(
PyListObject
*
self
,
PyObject
*
v
)
{
{
PyObject
*
v
;
if
(
!
PyArg_ParseTuple
(
args
,
"O:append"
,
&
v
))
return
NULL
;
return
ins
(
self
,
(
int
)
self
->
ob_size
,
v
);
return
ins
(
self
,
(
int
)
self
->
ob_size
,
v
);
}
}
...
@@ -702,14 +699,9 @@ list_inplace_concat(PyListObject *self, PyObject *other)
...
@@ -702,14 +699,9 @@ list_inplace_concat(PyListObject *self, PyObject *other)
}
}
static
PyObject
*
static
PyObject
*
listextend
(
PyListObject
*
self
,
PyObject
*
args
)
listextend
(
PyListObject
*
self
,
PyObject
*
b
)
{
{
PyObject
*
b
;
if
(
!
PyArg_ParseTuple
(
args
,
"O:extend"
,
&
b
))
return
NULL
;
b
=
PySequence_Fast
(
b
,
"list.extend() argument must be iterable"
);
b
=
PySequence_Fast
(
b
,
"list.extend() argument must be iterable"
);
if
(
!
b
)
if
(
!
b
)
return
NULL
;
return
NULL
;
...
@@ -1344,10 +1336,8 @@ _listreverse(PyListObject *self)
...
@@ -1344,10 +1336,8 @@ _listreverse(PyListObject *self)
}
}
static
PyObject
*
static
PyObject
*
listreverse
(
PyListObject
*
self
,
PyObject
*
args
)
listreverse
(
PyListObject
*
self
)
{
{
if
(
!
PyArg_ParseTuple
(
args
,
":reverse"
))
return
NULL
;
_listreverse
(
self
);
_listreverse
(
self
);
Py_INCREF
(
Py_None
);
Py_INCREF
(
Py_None
);
return
Py_None
;
return
Py_None
;
...
@@ -1390,13 +1380,10 @@ PyList_AsTuple(PyObject *v)
...
@@ -1390,13 +1380,10 @@ PyList_AsTuple(PyObject *v)
}
}
static
PyObject
*
static
PyObject
*
listindex
(
PyListObject
*
self
,
PyObject
*
args
)
listindex
(
PyListObject
*
self
,
PyObject
*
v
)
{
{
int
i
;
int
i
;
PyObject
*
v
;
if
(
!
PyArg_ParseTuple
(
args
,
"O:index"
,
&
v
))
return
NULL
;
for
(
i
=
0
;
i
<
self
->
ob_size
;
i
++
)
{
for
(
i
=
0
;
i
<
self
->
ob_size
;
i
++
)
{
int
cmp
=
PyObject_RichCompareBool
(
self
->
ob_item
[
i
],
v
,
Py_EQ
);
int
cmp
=
PyObject_RichCompareBool
(
self
->
ob_item
[
i
],
v
,
Py_EQ
);
if
(
cmp
>
0
)
if
(
cmp
>
0
)
...
@@ -1409,14 +1396,11 @@ listindex(PyListObject *self, PyObject *args)
...
@@ -1409,14 +1396,11 @@ listindex(PyListObject *self, PyObject *args)
}
}
static
PyObject
*
static
PyObject
*
listcount
(
PyListObject
*
self
,
PyObject
*
args
)
listcount
(
PyListObject
*
self
,
PyObject
*
v
)
{
{
int
count
=
0
;
int
count
=
0
;
int
i
;
int
i
;
PyObject
*
v
;
if
(
!
PyArg_ParseTuple
(
args
,
"O:count"
,
&
v
))
return
NULL
;
for
(
i
=
0
;
i
<
self
->
ob_size
;
i
++
)
{
for
(
i
=
0
;
i
<
self
->
ob_size
;
i
++
)
{
int
cmp
=
PyObject_RichCompareBool
(
self
->
ob_item
[
i
],
v
,
Py_EQ
);
int
cmp
=
PyObject_RichCompareBool
(
self
->
ob_item
[
i
],
v
,
Py_EQ
);
if
(
cmp
>
0
)
if
(
cmp
>
0
)
...
@@ -1428,13 +1412,10 @@ listcount(PyListObject *self, PyObject *args)
...
@@ -1428,13 +1412,10 @@ listcount(PyListObject *self, PyObject *args)
}
}
static
PyObject
*
static
PyObject
*
listremove
(
PyListObject
*
self
,
PyObject
*
args
)
listremove
(
PyListObject
*
self
,
PyObject
*
v
)
{
{
int
i
;
int
i
;
PyObject
*
v
;
if
(
!
PyArg_ParseTuple
(
args
,
"O:remove"
,
&
v
))
return
NULL
;
for
(
i
=
0
;
i
<
self
->
ob_size
;
i
++
)
{
for
(
i
=
0
;
i
<
self
->
ob_size
;
i
++
)
{
int
cmp
=
PyObject_RichCompareBool
(
self
->
ob_item
[
i
],
v
,
Py_EQ
);
int
cmp
=
PyObject_RichCompareBool
(
self
->
ob_item
[
i
],
v
,
Py_EQ
);
if
(
cmp
>
0
)
{
if
(
cmp
>
0
)
{
...
@@ -1661,14 +1642,14 @@ static char sort_doc[] =
...
@@ -1661,14 +1642,14 @@ static char sort_doc[] =
"L.sort([cmpfunc]) -- sort *IN PLACE*; if given, cmpfunc(x, y) -> -1, 0, 1"
;
"L.sort([cmpfunc]) -- sort *IN PLACE*; if given, cmpfunc(x, y) -> -1, 0, 1"
;
static
PyMethodDef
list_methods
[]
=
{
static
PyMethodDef
list_methods
[]
=
{
{
"append"
,
(
PyCFunction
)
listappend
,
METH_
VARARGS
,
append_doc
},
{
"append"
,
(
PyCFunction
)
listappend
,
METH_
O
,
append_doc
},
{
"insert"
,
(
PyCFunction
)
listinsert
,
METH_VARARGS
,
insert_doc
},
{
"insert"
,
(
PyCFunction
)
listinsert
,
METH_VARARGS
,
insert_doc
},
{
"extend"
,
(
PyCFunction
)
listextend
,
METH_
VARARGS
,
extend_doc
},
{
"extend"
,
(
PyCFunction
)
listextend
,
METH_
O
,
extend_doc
},
{
"pop"
,
(
PyCFunction
)
listpop
,
METH_VARARGS
,
pop_doc
},
{
"pop"
,
(
PyCFunction
)
listpop
,
METH_VARARGS
,
pop_doc
},
{
"remove"
,
(
PyCFunction
)
listremove
,
METH_
VARARGS
,
remove_doc
},
{
"remove"
,
(
PyCFunction
)
listremove
,
METH_
O
,
remove_doc
},
{
"index"
,
(
PyCFunction
)
listindex
,
METH_
VARARGS
,
index_doc
},
{
"index"
,
(
PyCFunction
)
listindex
,
METH_
O
,
index_doc
},
{
"count"
,
(
PyCFunction
)
listcount
,
METH_
VARARGS
,
count_doc
},
{
"count"
,
(
PyCFunction
)
listcount
,
METH_
O
,
count_doc
},
{
"reverse"
,
(
PyCFunction
)
listreverse
,
METH_
VAR
ARGS
,
reverse_doc
},
{
"reverse"
,
(
PyCFunction
)
listreverse
,
METH_
NO
ARGS
,
reverse_doc
},
{
"sort"
,
(
PyCFunction
)
listsort
,
METH_VARARGS
,
sort_doc
},
{
"sort"
,
(
PyCFunction
)
listsort
,
METH_VARARGS
,
sort_doc
},
{
NULL
,
NULL
}
/* sentinel */
{
NULL
,
NULL
}
/* sentinel */
};
};
...
@@ -1749,13 +1730,13 @@ immutable_list_op(void)
...
@@ -1749,13 +1730,13 @@ immutable_list_op(void)
}
}
static
PyMethodDef
immutable_list_methods
[]
=
{
static
PyMethodDef
immutable_list_methods
[]
=
{
{
"append"
,
(
PyCFunction
)
immutable_list_op
},
{
"append"
,
(
PyCFunction
)
immutable_list_op
,
METH_VARARGS
},
{
"insert"
,
(
PyCFunction
)
immutable_list_op
},
{
"insert"
,
(
PyCFunction
)
immutable_list_op
,
METH_VARARGS
},
{
"remove"
,
(
PyCFunction
)
immutable_list_op
},
{
"remove"
,
(
PyCFunction
)
immutable_list_op
,
METH_VARARGS
},
{
"index"
,
(
PyCFunction
)
listindex
},
{
"index"
,
(
PyCFunction
)
listindex
,
METH_O
},
{
"count"
,
(
PyCFunction
)
listcount
},
{
"count"
,
(
PyCFunction
)
listcount
,
METH_O
},
{
"reverse"
,
(
PyCFunction
)
immutable_list_op
},
{
"reverse"
,
(
PyCFunction
)
immutable_list_op
,
METH_VARARGS
},
{
"sort"
,
(
PyCFunction
)
immutable_list_op
},
{
"sort"
,
(
PyCFunction
)
immutable_list_op
,
METH_VARARGS
},
{
NULL
,
NULL
}
/* sentinel */
{
NULL
,
NULL
}
/* sentinel */
};
};
...
...
Objects/methodobject.c
View file @
e3eb1f2b
...
@@ -63,6 +63,7 @@ PyCFunction_Call(PyObject *func, PyObject *arg, PyObject *kw)
...
@@ -63,6 +63,7 @@ PyCFunction_Call(PyObject *func, PyObject *arg, PyObject *kw)
PyCFunction
meth
=
PyCFunction_GET_FUNCTION
(
func
);
PyCFunction
meth
=
PyCFunction_GET_FUNCTION
(
func
);
PyObject
*
self
=
PyCFunction_GET_SELF
(
func
);
PyObject
*
self
=
PyCFunction_GET_SELF
(
func
);
int
flags
=
PyCFunction_GET_FLAGS
(
func
);
int
flags
=
PyCFunction_GET_FLAGS
(
func
);
int
size
=
PyTuple_GET_SIZE
(
arg
);
if
(
flags
&
METH_KEYWORDS
)
{
if
(
flags
&
METH_KEYWORDS
)
{
return
(
*
(
PyCFunctionWithKeywords
)
meth
)(
self
,
arg
,
kw
);
return
(
*
(
PyCFunctionWithKeywords
)
meth
)(
self
,
arg
,
kw
);
...
@@ -73,21 +74,39 @@ PyCFunction_Call(PyObject *func, PyObject *arg, PyObject *kw)
...
@@ -73,21 +74,39 @@ PyCFunction_Call(PyObject *func, PyObject *arg, PyObject *kw)
f
->
m_ml
->
ml_name
);
f
->
m_ml
->
ml_name
);
return
NULL
;
return
NULL
;
}
}
if
(
flags
&
METH_VARARGS
)
{
switch
(
flags
)
{
case
METH_VARARGS
:
return
(
*
meth
)(
self
,
arg
);
return
(
*
meth
)(
self
,
arg
);
}
break
;
if
(
!
(
flags
&
METH_VARARGS
))
{
case
METH_NOARGS
:
if
(
size
==
0
)
return
(
*
meth
)(
self
,
NULL
);
PyErr_Format
(
PyExc_TypeError
,
"%.200s() takes no arguments (%d given)"
,
f
->
m_ml
->
ml_name
,
size
);
return
NULL
;
break
;
case
METH_O
:
if
(
size
==
1
)
return
(
*
meth
)(
self
,
PyTuple_GET_ITEM
(
arg
,
0
));
PyErr_Format
(
PyExc_TypeError
,
"%.200s() takes exactly one argument (%d given)"
,
f
->
m_ml
->
ml_name
,
size
);
return
NULL
;
break
;
case
METH_OLDARGS
:
/* the really old style */
/* the really old style */
int
size
=
PyTuple_GET_SIZE
(
arg
);
if
(
size
==
1
)
if
(
size
==
1
)
arg
=
PyTuple_GET_ITEM
(
arg
,
0
);
arg
=
PyTuple_GET_ITEM
(
arg
,
0
);
else
if
(
size
==
0
)
else
if
(
size
==
0
)
arg
=
NULL
;
arg
=
NULL
;
return
(
*
meth
)(
self
,
arg
);
return
(
*
meth
)(
self
,
arg
);
default:
/* should never get here ??? */
PyErr_BadInternalCall
();
return
NULL
;
}
}
/* should never get here ??? */
PyErr_BadInternalCall
();
return
NULL
;
}
}
/* Methods (the standard built-in methods, that is) */
/* Methods (the standard built-in methods, that is) */
...
...
Objects/rangeobject.c
View file @
e3eb1f2b
...
@@ -243,9 +243,6 @@ range_tolist(rangeobject *self, PyObject *args)
...
@@ -243,9 +243,6 @@ range_tolist(rangeobject *self, PyObject *args)
WARN
(
"xrange.tolist() is deprecated; use list(xrange) instead"
);
WARN
(
"xrange.tolist() is deprecated; use list(xrange) instead"
);
if
(
!
PyArg_ParseTuple
(
args
,
":tolist"
))
return
NULL
;
if
(
self
->
totlen
==
-
1
)
if
(
self
->
totlen
==
-
1
)
return
PyErr_NoMemory
();
return
PyErr_NoMemory
();
...
@@ -266,7 +263,7 @@ range_getattr(rangeobject *r, char *name)
...
@@ -266,7 +263,7 @@ range_getattr(rangeobject *r, char *name)
PyObject
*
result
;
PyObject
*
result
;
static
PyMethodDef
range_methods
[]
=
{
static
PyMethodDef
range_methods
[]
=
{
{
"tolist"
,
(
PyCFunction
)
range_tolist
,
METH_
VAR
ARGS
,
{
"tolist"
,
(
PyCFunction
)
range_tolist
,
METH_
NO
ARGS
,
"tolist() -> list
\n
"
"tolist() -> list
\n
"
"Return a list object with the same values.
\n
"
"Return a list object with the same values.
\n
"
"(This method is deprecated; use list() instead.)"
},
"(This method is deprecated; use list() instead.)"
},
...
...
Objects/stringobject.c
View file @
e3eb1f2b
This diff is collapsed.
Click to expand it.
Objects/typeobject.c
View file @
e3eb1f2b
...
@@ -376,12 +376,10 @@ mro_implementation(PyTypeObject *type)
...
@@ -376,12 +376,10 @@ mro_implementation(PyTypeObject *type)
}
}
static
PyObject
*
static
PyObject
*
mro_external
(
PyObject
*
self
,
PyObject
*
args
)
mro_external
(
PyObject
*
self
)
{
{
PyTypeObject
*
type
=
(
PyTypeObject
*
)
self
;
PyTypeObject
*
type
=
(
PyTypeObject
*
)
self
;
if
(
!
PyArg_ParseTuple
(
args
,
""
))
return
NULL
;
return
mro_implementation
(
type
);
return
mro_implementation
(
type
);
}
}
...
@@ -845,7 +843,7 @@ type_dealloc(PyTypeObject *type)
...
@@ -845,7 +843,7 @@ type_dealloc(PyTypeObject *type)
}
}
static
PyMethodDef
type_methods
[]
=
{
static
PyMethodDef
type_methods
[]
=
{
{
"mro"
,
mro_external
,
METH_VAR
ARGS
,
{
"mro"
,
(
PyCFunction
)
mro_external
,
METH_NO
ARGS
,
"mro() -> list
\n
return a type's method resolution order"
},
"mro() -> list
\n
return a type's method resolution order"
},
{
0
}
{
0
}
};
};
...
...
Objects/unicodeobject.c
View file @
e3eb1f2b
This diff is collapsed.
Click to expand it.
Python/bltinmodule.c
View file @
e3eb1f2b
...
@@ -53,12 +53,8 @@ fromlist is not empty.";
...
@@ -53,12 +53,8 @@ fromlist is not empty.";
static
PyObject
*
static
PyObject
*
builtin_abs
(
PyObject
*
self
,
PyObject
*
args
)
builtin_abs
(
PyObject
*
self
,
PyObject
*
v
)
{
{
PyObject
*
v
;
if
(
!
PyArg_ParseTuple
(
args
,
"O:abs"
,
&
v
))
return
NULL
;
return
PyNumber_Absolute
(
v
);
return
PyNumber_Absolute
(
v
);
}
}
...
@@ -132,12 +128,8 @@ extend to the end of the target object (or with the specified size).";
...
@@ -132,12 +128,8 @@ extend to the end of the target object (or with the specified size).";
static
PyObject
*
static
PyObject
*
builtin_callable
(
PyObject
*
self
,
PyObject
*
args
)
builtin_callable
(
PyObject
*
self
,
PyObject
*
v
)
{
{
PyObject
*
v
;
if
(
!
PyArg_ParseTuple
(
args
,
"O:callable"
,
&
v
))
return
NULL
;
return
PyInt_FromLong
((
long
)
PyCallable_Check
(
v
));
return
PyInt_FromLong
((
long
)
PyCallable_Check
(
v
));
}
}
...
@@ -667,12 +659,10 @@ exist; without it, an exception is raised in that case.";
...
@@ -667,12 +659,10 @@ exist; without it, an exception is raised in that case.";
static
PyObject
*
static
PyObject
*
builtin_globals
(
PyObject
*
self
,
PyObject
*
args
)
builtin_globals
(
PyObject
*
self
)
{
{
PyObject
*
d
;
PyObject
*
d
;
if
(
!
PyArg_ParseTuple
(
args
,
":globals"
))
return
NULL
;
d
=
PyEval_GetGlobals
();
d
=
PyEval_GetGlobals
();
Py_INCREF
(
d
);
Py_INCREF
(
d
);
return
d
;
return
d
;
...
@@ -722,12 +712,8 @@ Return whether the object has an attribute with the given name.\n\
...
@@ -722,12 +712,8 @@ Return whether the object has an attribute with the given name.\n\
static
PyObject
*
static
PyObject
*
builtin_id
(
PyObject
*
self
,
PyObject
*
args
)
builtin_id
(
PyObject
*
self
,
PyObject
*
v
)
{
{
PyObject
*
v
;
if
(
!
PyArg_ParseTuple
(
args
,
"O:id"
,
&
v
))
return
NULL
;
return
PyLong_FromVoidPtr
(
v
);
return
PyLong_FromVoidPtr
(
v
);
}
}
...
@@ -949,13 +935,10 @@ Delete a named attribute on an object; delattr(x, 'y') is equivalent to\n\
...
@@ -949,13 +935,10 @@ Delete a named attribute on an object; delattr(x, 'y') is equivalent to\n\
static
PyObject
*
static
PyObject
*
builtin_hash
(
PyObject
*
self
,
PyObject
*
args
)
builtin_hash
(
PyObject
*
self
,
PyObject
*
v
)
{
{
PyObject
*
v
;
long
x
;
long
x
;
if
(
!
PyArg_ParseTuple
(
args
,
"O:hash"
,
&
v
))
return
NULL
;
x
=
PyObject_Hash
(
v
);
x
=
PyObject_Hash
(
v
);
if
(
x
==
-
1
)
if
(
x
==
-
1
)
return
NULL
;
return
NULL
;
...
@@ -970,14 +953,10 @@ the same hash value. The reverse is not necessarily true, but likely.";
...
@@ -970,14 +953,10 @@ the same hash value. The reverse is not necessarily true, but likely.";
static
PyObject
*
static
PyObject
*
builtin_hex
(
PyObject
*
self
,
PyObject
*
args
)
builtin_hex
(
PyObject
*
self
,
PyObject
*
v
)
{
{
PyObject
*
v
;
PyNumberMethods
*
nb
;
PyNumberMethods
*
nb
;
if
(
!
PyArg_ParseTuple
(
args
,
"O:hex"
,
&
v
))
return
NULL
;
if
((
nb
=
v
->
ob_type
->
tp_as_number
)
==
NULL
||
if
((
nb
=
v
->
ob_type
->
tp_as_number
)
==
NULL
||
nb
->
nb_hex
==
NULL
)
{
nb
->
nb_hex
==
NULL
)
{
PyErr_SetString
(
PyExc_TypeError
,
PyErr_SetString
(
PyExc_TypeError
,
...
@@ -1075,13 +1054,10 @@ In the second form, the callable is called until it returns the sentinel.";
...
@@ -1075,13 +1054,10 @@ In the second form, the callable is called until it returns the sentinel.";
static
PyObject
*
static
PyObject
*
builtin_len
(
PyObject
*
self
,
PyObject
*
args
)
builtin_len
(
PyObject
*
self
,
PyObject
*
v
)
{
{
PyObject
*
v
;
long
res
;
long
res
;
if
(
!
PyArg_ParseTuple
(
args
,
"O:len"
,
&
v
))
return
NULL
;
res
=
PyObject_Size
(
v
);
res
=
PyObject_Size
(
v
);
if
(
res
<
0
&&
PyErr_Occurred
())
if
(
res
<
0
&&
PyErr_Occurred
())
return
NULL
;
return
NULL
;
...
@@ -1120,12 +1096,10 @@ Create a slice object. This is used for slicing by the Numeric extensions.";
...
@@ -1120,12 +1096,10 @@ Create a slice object. This is used for slicing by the Numeric extensions.";
static
PyObject
*
static
PyObject
*
builtin_locals
(
PyObject
*
self
,
PyObject
*
args
)
builtin_locals
(
PyObject
*
self
)
{
{
PyObject
*
d
;
PyObject
*
d
;
if
(
!
PyArg_ParseTuple
(
args
,
":locals"
))
return
NULL
;
d
=
PyEval_GetLocals
();
d
=
PyEval_GetLocals
();
Py_INCREF
(
d
);
Py_INCREF
(
d
);
return
d
;
return
d
;
...
@@ -1217,13 +1191,10 @@ With two or more arguments, return the largest argument.";
...
@@ -1217,13 +1191,10 @@ With two or more arguments, return the largest argument.";
static
PyObject
*
static
PyObject
*
builtin_oct
(
PyObject
*
self
,
PyObject
*
args
)
builtin_oct
(
PyObject
*
self
,
PyObject
*
v
)
{
{
PyObject
*
v
;
PyNumberMethods
*
nb
;
PyNumberMethods
*
nb
;
if
(
!
PyArg_ParseTuple
(
args
,
"O:oct"
,
&
v
))
return
NULL
;
if
(
v
==
NULL
||
(
nb
=
v
->
ob_type
->
tp_as_number
)
==
NULL
||
if
(
v
==
NULL
||
(
nb
=
v
->
ob_type
->
tp_as_number
)
==
NULL
||
nb
->
nb_oct
==
NULL
)
{
nb
->
nb_oct
==
NULL
)
{
PyErr_SetString
(
PyExc_TypeError
,
PyErr_SetString
(
PyExc_TypeError
,
...
@@ -1270,15 +1241,11 @@ buffered, and larger numbers specify the buffer size.";
...
@@ -1270,15 +1241,11 @@ buffered, and larger numbers specify the buffer size.";
static
PyObject
*
static
PyObject
*
builtin_ord
(
PyObject
*
self
,
PyObject
*
args
)
builtin_ord
(
PyObject
*
self
,
PyObject
*
obj
)
{
{
PyObject
*
obj
;
long
ord
;
long
ord
;
int
size
;
int
size
;
if
(
!
PyArg_ParseTuple
(
args
,
"O:ord"
,
&
obj
))
return
NULL
;
if
(
PyString_Check
(
obj
))
{
if
(
PyString_Check
(
obj
))
{
size
=
PyString_GET_SIZE
(
obj
);
size
=
PyString_GET_SIZE
(
obj
);
if
(
size
==
1
)
{
if
(
size
==
1
)
{
...
@@ -1611,12 +1578,8 @@ sequence is empty.";
...
@@ -1611,12 +1578,8 @@ sequence is empty.";
static
PyObject
*
static
PyObject
*
builtin_reload
(
PyObject
*
self
,
PyObject
*
args
)
builtin_reload
(
PyObject
*
self
,
PyObject
*
v
)
{
{
PyObject
*
v
;
if
(
!
PyArg_ParseTuple
(
args
,
"O:reload"
,
&
v
))
return
NULL
;
return
PyImport_ReloadModule
(
v
);
return
PyImport_ReloadModule
(
v
);
}
}
...
@@ -1627,12 +1590,8 @@ Reload the module. The module must have been successfully imported before.";
...
@@ -1627,12 +1590,8 @@ Reload the module. The module must have been successfully imported before.";
static
PyObject
*
static
PyObject
*
builtin_repr
(
PyObject
*
self
,
PyObject
*
args
)
builtin_repr
(
PyObject
*
self
,
PyObject
*
v
)
{
{
PyObject
*
v
;
if
(
!
PyArg_ParseTuple
(
args
,
"O:repr"
,
&
v
))
return
NULL
;
return
PyObject_Repr
(
v
);
return
PyObject_Repr
(
v
);
}
}
...
@@ -1841,53 +1800,53 @@ in length to the length of the shortest argument sequence.";
...
@@ -1841,53 +1800,53 @@ in length to the length of the shortest argument sequence.";
static
PyMethodDef
builtin_methods
[]
=
{
static
PyMethodDef
builtin_methods
[]
=
{
{
"__import__"
,
builtin___import__
,
1
,
import_doc
},
{
"__import__"
,
builtin___import__
,
METH_VARARGS
,
import_doc
},
{
"abs"
,
builtin_abs
,
1
,
abs_doc
},
{
"abs"
,
builtin_abs
,
METH_O
,
abs_doc
},
{
"apply"
,
builtin_apply
,
1
,
apply_doc
},
{
"apply"
,
builtin_apply
,
METH_VARARGS
,
apply_doc
},
{
"buffer"
,
builtin_buffer
,
1
,
buffer_doc
},
{
"buffer"
,
builtin_buffer
,
METH_VARARGS
,
buffer_doc
},
{
"callable"
,
builtin_callable
,
1
,
callable_doc
},
{
"callable"
,
builtin_callable
,
METH_O
,
callable_doc
},
{
"chr"
,
builtin_chr
,
1
,
chr_doc
},
{
"chr"
,
builtin_chr
,
METH_VARARGS
,
chr_doc
},
{
"cmp"
,
builtin_cmp
,
1
,
cmp_doc
},
{
"cmp"
,
builtin_cmp
,
METH_VARARGS
,
cmp_doc
},
{
"coerce"
,
builtin_coerce
,
1
,
coerce_doc
},
{
"coerce"
,
builtin_coerce
,
METH_VARARGS
,
coerce_doc
},
{
"compile"
,
builtin_compile
,
1
,
compile_doc
},
{
"compile"
,
builtin_compile
,
METH_VARARGS
,
compile_doc
},
{
"delattr"
,
builtin_delattr
,
1
,
delattr_doc
},
{
"delattr"
,
builtin_delattr
,
METH_VARARGS
,
delattr_doc
},
{
"dir"
,
builtin_dir
,
1
,
dir_doc
},
{
"dir"
,
builtin_dir
,
METH_VARARGS
,
dir_doc
},
{
"divmod"
,
builtin_divmod
,
1
,
divmod_doc
},
{
"divmod"
,
builtin_divmod
,
METH_VARARGS
,
divmod_doc
},
{
"eval"
,
builtin_eval
,
1
,
eval_doc
},
{
"eval"
,
builtin_eval
,
METH_VARARGS
,
eval_doc
},
{
"execfile"
,
builtin_execfile
,
1
,
execfile_doc
},
{
"execfile"
,
builtin_execfile
,
METH_VARARGS
,
execfile_doc
},
{
"filter"
,
builtin_filter
,
1
,
filter_doc
},
{
"filter"
,
builtin_filter
,
METH_VARARGS
,
filter_doc
},
{
"getattr"
,
builtin_getattr
,
1
,
getattr_doc
},
{
"getattr"
,
builtin_getattr
,
METH_VARARGS
,
getattr_doc
},
{
"globals"
,
builtin_globals
,
1
,
globals_doc
},
{
"globals"
,
(
PyCFunction
)
builtin_globals
,
METH_NOARGS
,
globals_doc
},
{
"hasattr"
,
builtin_hasattr
,
1
,
hasattr_doc
},
{
"hasattr"
,
builtin_hasattr
,
METH_VARARGS
,
hasattr_doc
},
{
"hash"
,
builtin_hash
,
1
,
hash_doc
},
{
"hash"
,
builtin_hash
,
METH_O
,
hash_doc
},
{
"hex"
,
builtin_hex
,
1
,
hex_doc
},
{
"hex"
,
builtin_hex
,
METH_O
,
hex_doc
},
{
"id"
,
builtin_id
,
1
,
id_doc
},
{
"id"
,
builtin_id
,
METH_O
,
id_doc
},
{
"input"
,
builtin_input
,
1
,
input_doc
},
{
"input"
,
builtin_input
,
METH_VARARGS
,
input_doc
},
{
"intern"
,
builtin_intern
,
1
,
intern_doc
},
{
"intern"
,
builtin_intern
,
METH_VARARGS
,
intern_doc
},
{
"isinstance"
,
builtin_isinstance
,
1
,
isinstance_doc
},
{
"isinstance"
,
builtin_isinstance
,
METH_VARARGS
,
isinstance_doc
},
{
"issubclass"
,
builtin_issubclass
,
1
,
issubclass_doc
},
{
"issubclass"
,
builtin_issubclass
,
METH_VARARGS
,
issubclass_doc
},
{
"iter"
,
builtin_iter
,
1
,
iter_doc
},
{
"iter"
,
builtin_iter
,
METH_VARARGS
,
iter_doc
},
{
"len"
,
builtin_len
,
1
,
len_doc
},
{
"len"
,
builtin_len
,
METH_O
,
len_doc
},
{
"locals"
,
builtin_locals
,
1
,
locals_doc
},
{
"locals"
,
(
PyCFunction
)
builtin_locals
,
METH_NOARGS
,
locals_doc
},
{
"map"
,
builtin_map
,
1
,
map_doc
},
{
"map"
,
builtin_map
,
METH_VARARGS
,
map_doc
},
{
"max"
,
builtin_max
,
1
,
max_doc
},
{
"max"
,
builtin_max
,
METH_VARARGS
,
max_doc
},
{
"min"
,
builtin_min
,
1
,
min_doc
},
{
"min"
,
builtin_min
,
METH_VARARGS
,
min_doc
},
{
"oct"
,
builtin_oct
,
1
,
oct_doc
},
{
"oct"
,
builtin_oct
,
METH_O
,
oct_doc
},
{
"open"
,
builtin_open
,
1
,
open_doc
},
{
"open"
,
builtin_open
,
METH_VARARGS
,
open_doc
},
{
"ord"
,
builtin_ord
,
1
,
ord_doc
},
{
"ord"
,
builtin_ord
,
METH_O
,
ord_doc
},
{
"pow"
,
builtin_pow
,
1
,
pow_doc
},
{
"pow"
,
builtin_pow
,
METH_VARARGS
,
pow_doc
},
{
"range"
,
builtin_range
,
1
,
range_doc
},
{
"range"
,
builtin_range
,
METH_VARARGS
,
range_doc
},
{
"raw_input"
,
builtin_raw_input
,
1
,
raw_input_doc
},
{
"raw_input"
,
builtin_raw_input
,
METH_VARARGS
,
raw_input_doc
},
{
"reduce"
,
builtin_reduce
,
1
,
reduce_doc
},
{
"reduce"
,
builtin_reduce
,
METH_VARARGS
,
reduce_doc
},
{
"reload"
,
builtin_reload
,
1
,
reload_doc
},
{
"reload"
,
builtin_reload
,
METH_O
,
reload_doc
},
{
"repr"
,
builtin_repr
,
1
,
repr_doc
},
{
"repr"
,
builtin_repr
,
METH_O
,
repr_doc
},
{
"round"
,
builtin_round
,
1
,
round_doc
},
{
"round"
,
builtin_round
,
METH_VARARGS
,
round_doc
},
{
"setattr"
,
builtin_setattr
,
1
,
setattr_doc
},
{
"setattr"
,
builtin_setattr
,
METH_VARARGS
,
setattr_doc
},
{
"slice"
,
builtin_slice
,
1
,
slice_doc
},
{
"slice"
,
builtin_slice
,
METH_VARARGS
,
slice_doc
},
{
"unichr"
,
builtin_unichr
,
1
,
unichr_doc
},
{
"unichr"
,
builtin_unichr
,
METH_VARARGS
,
unichr_doc
},
{
"vars"
,
builtin_vars
,
1
,
vars_doc
},
{
"vars"
,
builtin_vars
,
METH_VARARGS
,
vars_doc
},
{
"xrange"
,
builtin_xrange
,
1
,
xrange_doc
},
{
"xrange"
,
builtin_xrange
,
METH_VARARGS
,
xrange_doc
},
{
"zip"
,
builtin_zip
,
1
,
zip_doc
},
{
"zip"
,
builtin_zip
,
METH_VARARGS
,
zip_doc
},
{
NULL
,
NULL
},
{
NULL
,
NULL
},
};
};
...
...
Python/ceval.c
View file @
e3eb1f2b
...
@@ -166,13 +166,10 @@ gen_iternext(genobject *gen)
...
@@ -166,13 +166,10 @@ gen_iternext(genobject *gen)
}
}
static
PyObject
*
static
PyObject
*
gen_next
(
genobject
*
gen
,
PyObject
*
args
)
gen_next
(
genobject
*
gen
)
{
{
PyObject
*
result
;
PyObject
*
result
;
if
(
!
PyArg_ParseTuple
(
args
,
":next"
))
return
NULL
;
result
=
gen_iternext
(
gen
);
result
=
gen_iternext
(
gen
);
if
(
result
==
NULL
&&
!
PyErr_Occurred
())
{
if
(
result
==
NULL
&&
!
PyErr_Occurred
())
{
...
@@ -191,7 +188,7 @@ gen_getiter(PyObject *gen)
...
@@ -191,7 +188,7 @@ gen_getiter(PyObject *gen)
}
}
static
struct
PyMethodDef
gen_methods
[]
=
{
static
struct
PyMethodDef
gen_methods
[]
=
{
{
"next"
,
(
PyCFunction
)
gen_next
,
METH_
VAR
ARGS
,
{
"next"
,
(
PyCFunction
)
gen_next
,
METH_
NO
ARGS
,
"next() -- get the next value, or raise StopIteration"
},
"next() -- get the next value, or raise StopIteration"
},
{
NULL
,
NULL
}
/* Sentinel */
{
NULL
,
NULL
}
/* Sentinel */
};
};
...
@@ -1938,7 +1935,7 @@ eval_frame(PyFrameObject *f)
...
@@ -1938,7 +1935,7 @@ eval_frame(PyFrameObject *f)
*/
*/
if
(
PyCFunction_Check
(
func
))
{
if
(
PyCFunction_Check
(
func
))
{
int
flags
=
PyCFunction_GET_FLAGS
(
func
);
int
flags
=
PyCFunction_GET_FLAGS
(
func
);
if
(
flags
>
1
||
nk
!=
0
)
if
(
nk
!=
0
||
(
flags
&
METH_KEYWORDS
))
x
=
do_call
(
func
,
&
stack_pointer
,
x
=
do_call
(
func
,
&
stack_pointer
,
na
,
nk
);
na
,
nk
);
else
if
(
flags
==
METH_VARARGS
)
{
else
if
(
flags
==
METH_VARARGS
)
{
...
@@ -1946,9 +1943,9 @@ eval_frame(PyFrameObject *f)
...
@@ -1946,9 +1943,9 @@ eval_frame(PyFrameObject *f)
callargs
=
load_args
(
&
stack_pointer
,
na
);
callargs
=
load_args
(
&
stack_pointer
,
na
);
x
=
PyCFunction_Call
(
func
,
callargs
,
NULL
);
x
=
PyCFunction_Call
(
func
,
callargs
,
NULL
);
Py_XDECREF
(
callargs
);
Py_XDECREF
(
callargs
);
}
else
if
(
!
(
flags
&
METH_KEYWORDS
))
}
else
x
=
fast_cfunction
(
func
,
x
=
fast_cfunction
(
func
,
&
stack_pointer
,
na
);
&
stack_pointer
,
na
);
}
else
{
}
else
{
if
(
PyMethod_Check
(
func
)
if
(
PyMethod_Check
(
func
)
&&
PyMethod_GET_SELF
(
func
)
!=
NULL
)
{
&&
PyMethod_GET_SELF
(
func
)
!=
NULL
)
{
...
@@ -3046,20 +3043,50 @@ fast_cfunction(PyObject *func, PyObject ***pp_stack, int na)
...
@@ -3046,20 +3043,50 @@ fast_cfunction(PyObject *func, PyObject ***pp_stack, int na)
{
{
PyCFunction
meth
=
PyCFunction_GET_FUNCTION
(
func
);
PyCFunction
meth
=
PyCFunction_GET_FUNCTION
(
func
);
PyObject
*
self
=
PyCFunction_GET_SELF
(
func
);
PyObject
*
self
=
PyCFunction_GET_SELF
(
func
);
int
flags
=
PyCFunction_GET_FLAGS
(
func
);
if
(
na
==
0
)
return
(
*
meth
)(
self
,
NULL
);
switch
(
flags
)
{
else
if
(
na
==
1
)
{
case
METH_OLDARGS
:
PyObject
*
arg
=
EXT_POP
(
*
pp_stack
);
if
(
na
==
0
)
PyObject
*
result
=
(
*
meth
)(
self
,
arg
);
return
(
*
meth
)(
self
,
NULL
);
Py_DECREF
(
arg
);
else
if
(
na
==
1
)
{
return
result
;
PyObject
*
arg
=
EXT_POP
(
*
pp_stack
);
}
else
{
PyObject
*
result
=
(
*
meth
)(
self
,
arg
);
PyObject
*
args
=
load_args
(
pp_stack
,
na
);
Py_DECREF
(
arg
);
PyObject
*
result
=
(
*
meth
)(
self
,
args
);
return
result
;
Py_DECREF
(
args
);
}
else
{
return
result
;
PyObject
*
args
=
load_args
(
pp_stack
,
na
);
}
PyObject
*
result
=
(
*
meth
)(
self
,
args
);
Py_DECREF
(
args
);
return
result
;
}
break
;
case
METH_NOARGS
:
if
(
na
==
0
)
return
(
*
meth
)(
self
,
NULL
);
PyErr_Format
(
PyExc_TypeError
,
"%.200s() takes no arguments (%d given)"
,
((
PyCFunctionObject
*
)
func
)
->
m_ml
->
ml_name
,
na
);
return
NULL
;
break
;
case
METH_O
:
if
(
na
==
1
)
{
PyObject
*
arg
=
EXT_POP
(
*
pp_stack
);
PyObject
*
result
=
(
*
meth
)(
self
,
arg
);
Py_DECREF
(
arg
);
return
result
;
}
PyErr_Format
(
PyExc_TypeError
,
"%.200s() takes exactly one argument (%d given)"
,
((
PyCFunctionObject
*
)
func
)
->
m_ml
->
ml_name
,
na
);
return
NULL
;
break
;
default:
fprintf
(
stderr
,
"%.200s() flags = %d
\n
"
,
((
PyCFunctionObject
*
)
func
)
->
m_ml
->
ml_name
,
flags
);
PyErr_BadInternalCall
();
return
NULL
;
}
}
}
static
PyObject
*
static
PyObject
*
...
...
Python/sysmodule.c
View file @
e3eb1f2b
...
@@ -68,9 +68,9 @@ PySys_SetObject(char *name, PyObject *v)
...
@@ -68,9 +68,9 @@ PySys_SetObject(char *name, PyObject *v)
}
}
static
PyObject
*
static
PyObject
*
sys_displayhook
(
PyObject
*
self
,
PyObject
*
args
)
sys_displayhook
(
PyObject
*
self
,
PyObject
*
o
)
{
{
PyObject
*
o
,
*
o
utf
;
PyObject
*
outf
;
PyInterpreterState
*
interp
=
PyThreadState_Get
()
->
interp
;
PyInterpreterState
*
interp
=
PyThreadState_Get
()
->
interp
;
PyObject
*
modules
=
interp
->
modules
;
PyObject
*
modules
=
interp
->
modules
;
PyObject
*
builtins
=
PyDict_GetItemString
(
modules
,
"__builtin__"
);
PyObject
*
builtins
=
PyDict_GetItemString
(
modules
,
"__builtin__"
);
...
@@ -80,10 +80,6 @@ sys_displayhook(PyObject *self, PyObject *args)
...
@@ -80,10 +80,6 @@ sys_displayhook(PyObject *self, PyObject *args)
return
NULL
;
return
NULL
;
}
}
/* parse arguments */
if
(
!
PyArg_ParseTuple
(
args
,
"O:displayhook"
,
&
o
))
return
NULL
;
/* Print value except if None */
/* Print value except if None */
/* After printing, also assign to '_' */
/* After printing, also assign to '_' */
/* Before, set '_' to None to avoid recursion */
/* Before, set '_' to None to avoid recursion */
...
@@ -133,11 +129,9 @@ static char excepthook_doc[] =
...
@@ -133,11 +129,9 @@ static char excepthook_doc[] =
"Handle an exception by displaying it with a traceback on sys.stderr.
\n
"
;
"Handle an exception by displaying it with a traceback on sys.stderr.
\n
"
;
static
PyObject
*
static
PyObject
*
sys_exc_info
(
PyObject
*
self
,
PyObject
*
args
)
sys_exc_info
(
PyObject
*
self
)
{
{
PyThreadState
*
tstate
;
PyThreadState
*
tstate
;
if
(
!
PyArg_ParseTuple
(
args
,
":exc_info"
))
return
NULL
;
tstate
=
PyThreadState_Get
();
tstate
=
PyThreadState_Get
();
return
Py_BuildValue
(
return
Py_BuildValue
(
"(OOO)"
,
"(OOO)"
,
...
@@ -171,10 +165,8 @@ If it is another kind of object, it will be printed and the system\n\
...
@@ -171,10 +165,8 @@ If it is another kind of object, it will be printed and the system\n\
exit status will be one (i.e., failure)."
;
exit status will be one (i.e., failure)."
;
static
PyObject
*
static
PyObject
*
sys_getdefaultencoding
(
PyObject
*
self
,
PyObject
*
args
)
sys_getdefaultencoding
(
PyObject
*
self
)
{
{
if
(
!
PyArg_ParseTuple
(
args
,
":getdefaultencoding"
))
return
NULL
;
return
PyString_FromString
(
PyUnicode_GetDefaultEncoding
());
return
PyString_FromString
(
PyUnicode_GetDefaultEncoding
());
}
}
...
@@ -385,10 +377,8 @@ stack and crashing Python. The highest possible limit is platform-\n\
...
@@ -385,10 +377,8 @@ stack and crashing Python. The highest possible limit is platform-\n\
dependent."
;
dependent."
;
static
PyObject
*
static
PyObject
*
sys_getrecursionlimit
(
PyObject
*
self
,
PyObject
*
args
)
sys_getrecursionlimit
(
PyObject
*
self
)
{
{
if
(
!
PyArg_ParseTuple
(
args
,
":getrecursionlimit"
))
return
NULL
;
return
PyInt_FromLong
(
Py_GetRecursionLimit
());
return
PyInt_FromLong
(
Py_GetRecursionLimit
());
}
}
...
@@ -427,8 +417,6 @@ static PyObject *
...
@@ -427,8 +417,6 @@ static PyObject *
sys_getdlopenflags
(
PyObject
*
self
,
PyObject
*
args
)
sys_getdlopenflags
(
PyObject
*
self
,
PyObject
*
args
)
{
{
PyThreadState
*
tstate
=
PyThreadState_Get
();
PyThreadState
*
tstate
=
PyThreadState_Get
();
if
(
!
PyArg_ParseTuple
(
args
,
":getdlopenflags"
))
return
NULL
;
if
(
!
tstate
)
if
(
!
tstate
)
return
NULL
;
return
NULL
;
return
PyInt_FromLong
(
tstate
->
interp
->
dlopenflags
);
return
PyInt_FromLong
(
tstate
->
interp
->
dlopenflags
);
...
@@ -468,11 +456,9 @@ sys_getrefcount(PyObject *self, PyObject *args)
...
@@ -468,11 +456,9 @@ sys_getrefcount(PyObject *self, PyObject *args)
#ifdef Py_TRACE_REFS
#ifdef Py_TRACE_REFS
static
PyObject
*
static
PyObject
*
sys_gettotalrefcount
(
PyObject
*
self
,
PyObject
*
args
)
sys_gettotalrefcount
(
PyObject
*
self
)
{
{
extern
long
_Py_RefTotal
;
extern
long
_Py_RefTotal
;
if
(
!
PyArg_ParseTuple
(
args
,
":gettotalrefcount"
))
return
NULL
;
return
PyInt_FromLong
(
_Py_RefTotal
);
return
PyInt_FromLong
(
_Py_RefTotal
);
}
}
...
@@ -486,12 +472,10 @@ temporary reference in the argument list, so it is at least 2.";
...
@@ -486,12 +472,10 @@ temporary reference in the argument list, so it is at least 2.";
#ifdef COUNT_ALLOCS
#ifdef COUNT_ALLOCS
static
PyObject
*
static
PyObject
*
sys_getcounts
(
PyObject
*
self
,
PyObject
*
args
)
sys_getcounts
(
PyObject
*
self
)
{
{
extern
PyObject
*
get_counts
(
void
);
extern
PyObject
*
get_counts
(
void
);
if
(
!
PyArg_ParseTuple
(
args
,
":getcounts"
))
return
NULL
;
return
get_counts
();
return
get_counts
();
}
}
#endif
#endif
...
@@ -542,45 +526,45 @@ extern PyObject *_Py_GetDXProfile(PyObject *, PyObject *);
...
@@ -542,45 +526,45 @@ extern PyObject *_Py_GetDXProfile(PyObject *, PyObject *);
static
PyMethodDef
sys_methods
[]
=
{
static
PyMethodDef
sys_methods
[]
=
{
/* Might as well keep this in alphabetic order */
/* Might as well keep this in alphabetic order */
{
"displayhook"
,
sys_displayhook
,
1
,
displayhook_doc
},
{
"displayhook"
,
sys_displayhook
,
METH_O
,
displayhook_doc
},
{
"exc_info"
,
sys_exc_info
,
1
,
exc_info_doc
},
{
"exc_info"
,
(
PyCFunction
)
sys_exc_info
,
METH_NOARGS
,
exc_info_doc
},
{
"excepthook"
,
sys_excepthook
,
1
,
excepthook_doc
},
{
"excepthook"
,
sys_excepthook
,
METH_VARARGS
,
excepthook_doc
},
{
"exit"
,
sys_exit
,
0
,
exit_doc
},
{
"exit"
,
sys_exit
,
METH_OLDARGS
,
exit_doc
},
{
"getdefaultencoding"
,
sys_getdefaultencoding
,
1
,
{
"getdefaultencoding"
,
(
PyCFunction
)
sys_getdefaultencoding
,
METH_NOARGS
,
getdefaultencoding_doc
},
getdefaultencoding_doc
},
#ifdef HAVE_DLOPEN
#ifdef HAVE_DLOPEN
{
"getdlopenflags"
,
sys_getdlopenflags
,
1
,
{
"getdlopenflags"
,
(
PyCFunction
)
sys_getdlopenflags
,
METH_NOARGS
,
getdlopenflags_doc
},
getdlopenflags_doc
},
#endif
#endif
#ifdef COUNT_ALLOCS
#ifdef COUNT_ALLOCS
{
"getcounts"
,
sys_getcounts
,
1
},
{
"getcounts"
,
(
PyCFunction
)
sys_getcounts
,
METH_NOARGS
},
#endif
#endif
#ifdef DYNAMIC_EXECUTION_PROFILE
#ifdef DYNAMIC_EXECUTION_PROFILE
{
"getdxp"
,
_Py_GetDXProfile
,
1
},
{
"getdxp"
,
_Py_GetDXProfile
,
METH_VARARGS
},
#endif
#endif
#ifdef Py_TRACE_REFS
#ifdef Py_TRACE_REFS
{
"getobjects"
,
_Py_GetObjects
,
1
},
{
"getobjects"
,
_Py_GetObjects
,
METH_VARARGS
},
{
"gettotalrefcount"
,
sys_gettotalrefcount
,
1
},
{
"gettotalrefcount"
,
(
PyCFunction
)
sys_gettotalrefcount
,
METH_NOARGS
},
#endif
#endif
{
"getrefcount"
,
sys_getrefcount
,
1
,
getrefcount_doc
},
{
"getrefcount"
,
sys_getrefcount
,
METH_VARARGS
,
getrefcount_doc
},
{
"getrecursionlimit"
,
sys_getrecursionlimit
,
1
,
{
"getrecursionlimit"
,
(
PyCFunction
)
sys_getrecursionlimit
,
METH_NOARGS
,
getrecursionlimit_doc
},
getrecursionlimit_doc
},
{
"_getframe"
,
sys_getframe
,
1
,
getframe_doc
},
{
"_getframe"
,
sys_getframe
,
METH_VARARGS
,
getframe_doc
},
#ifdef USE_MALLOPT
#ifdef USE_MALLOPT
{
"mdebug"
,
sys_mdebug
,
1
},
{
"mdebug"
,
sys_mdebug
,
METH_VARARGS
},
#endif
#endif
{
"setdefaultencoding"
,
sys_setdefaultencoding
,
1
,
{
"setdefaultencoding"
,
sys_setdefaultencoding
,
METH_VARARGS
,
setdefaultencoding_doc
},
setdefaultencoding_doc
},
{
"setcheckinterval"
,
sys_setcheckinterval
,
1
,
{
"setcheckinterval"
,
sys_setcheckinterval
,
METH_VARARGS
,
setcheckinterval_doc
},
setcheckinterval_doc
},
#ifdef HAVE_DLOPEN
#ifdef HAVE_DLOPEN
{
"setdlopenflags"
,
sys_setdlopenflags
,
1
,
{
"setdlopenflags"
,
sys_setdlopenflags
,
METH_VARARGS
,
setdlopenflags_doc
},
setdlopenflags_doc
},
#endif
#endif
{
"setprofile"
,
sys_setprofile
,
0
,
setprofile_doc
},
{
"setprofile"
,
sys_setprofile
,
METH_OLDARGS
,
setprofile_doc
},
{
"setrecursionlimit"
,
sys_setrecursionlimit
,
1
,
{
"setrecursionlimit"
,
sys_setrecursionlimit
,
METH_VARARGS
,
setrecursionlimit_doc
},
setrecursionlimit_doc
},
{
"settrace"
,
sys_settrace
,
0
,
settrace_doc
},
{
"settrace"
,
sys_settrace
,
METH_OLDARGS
,
settrace_doc
},
{
NULL
,
NULL
}
/* sentinel */
{
NULL
,
NULL
}
/* sentinel */
};
};
...
...
configure
View file @
e3eb1f2b
#! /bin/sh
#! /bin/sh
# From configure.in Revision: 1.24
6
# From configure.in Revision: 1.24
7
# Guess values for system-dependent variables and create Makefiles.
# Guess values for system-dependent variables and create Makefiles.
# Generated automatically using autoconf version 2.13
# Generated automatically using autoconf version 2.13
...
...
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