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
eb079f1c
Commit
eb079f1c
authored
Feb 16, 2006
by
Martin v. Löwis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use Py_ssize_t for counts and sizes.
Convert Py_ssize_t using PyInt_FromSsize_t
parent
ad0a4629
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
33 additions
and
31 deletions
+33
-31
Objects/abstract.c
Objects/abstract.c
+2
-2
Objects/enumobject.c
Objects/enumobject.c
+3
-3
Objects/iterobject.c
Objects/iterobject.c
+1
-1
Objects/listobject.c
Objects/listobject.c
+4
-4
Objects/methodobject.c
Objects/methodobject.c
+3
-3
Objects/stringobject.c
Objects/stringobject.c
+5
-5
Objects/structseq.c
Objects/structseq.c
+1
-1
Objects/tupleobject.c
Objects/tupleobject.c
+4
-3
Objects/typeobject.c
Objects/typeobject.c
+9
-8
Objects/unicodeobject.c
Objects/unicodeobject.c
+1
-1
No files found.
Objects/abstract.c
View file @
eb079f1c
...
...
@@ -1170,7 +1170,7 @@ PySequence_Repeat(PyObject *o, Py_ssize_t count)
to nb_multiply if o appears to be a sequence. */
if
(
PySequence_Check
(
o
))
{
PyObject
*
n
,
*
result
;
n
=
PyInt_From
Long
(
count
);
n
=
PyInt_From
Ssize_t
(
count
);
if
(
n
==
NULL
)
return
NULL
;
result
=
binary_op1
(
o
,
n
,
NB_SLOT
(
nb_multiply
));
...
...
@@ -1222,7 +1222,7 @@ PySequence_InPlaceRepeat(PyObject *o, Py_ssize_t count)
if
(
PySequence_Check
(
o
))
{
PyObject
*
n
,
*
result
;
n
=
PyInt_From
Long
(
count
);
n
=
PyInt_From
Ssize_t
(
count
);
if
(
n
==
NULL
)
return
NULL
;
result
=
binary_iop1
(
o
,
n
,
NB_SLOT
(
nb_inplace_multiply
),
...
...
Objects/enumobject.c
View file @
eb079f1c
...
...
@@ -159,14 +159,14 @@ PyTypeObject PyEnum_Type = {
typedef
struct
{
PyObject_HEAD
long
index
;
Py_ssize_t
index
;
PyObject
*
seq
;
}
reversedobject
;
static
PyObject
*
reversed_new
(
PyTypeObject
*
type
,
PyObject
*
args
,
PyObject
*
kwds
)
{
long
n
;
Py_ssize_t
n
;
PyObject
*
seq
;
reversedobject
*
ro
;
...
...
@@ -249,7 +249,7 @@ reversed_len(reversedobject *ro)
if
(
seqsize
==
-
1
)
return
NULL
;
position
=
ro
->
index
+
1
;
return
PyInt_From
Long
((
seqsize
<
position
)
?
0
:
position
);
return
PyInt_From
Ssize_t
((
seqsize
<
position
)
?
0
:
position
);
}
PyDoc_STRVAR
(
length_hint_doc
,
"Private method returning an estimate of len(list(it))."
);
...
...
Objects/iterobject.c
View file @
eb079f1c
...
...
@@ -82,7 +82,7 @@ iter_len(seqiterobject *it)
return
NULL
;
len
=
seqsize
-
it
->
it_index
;
if
(
len
>=
0
)
return
PyInt_From
Long
(
len
);
return
PyInt_From
Ssize_t
(
len
);
}
return
PyInt_FromLong
(
0
);
}
...
...
Objects/listobject.c
View file @
eb079f1c
...
...
@@ -2504,13 +2504,13 @@ static int
list_ass_subscript
(
PyListObject
*
self
,
PyObject
*
item
,
PyObject
*
value
)
{
if
(
PyInt_Check
(
item
))
{
long
i
=
PyInt_AS_LONG
(
item
);
Py_ssize_t
i
=
PyInt_AS_LONG
(
item
);
if
(
i
<
0
)
i
+=
PyList_GET_SIZE
(
self
);
return
list_ass_item
(
self
,
i
,
value
);
}
else
if
(
PyLong_Check
(
item
))
{
long
i
=
PyLong_AsLong
(
item
);
Py_ssize_t
i
=
PyInt_AsSsize_t
(
item
);
if
(
i
==
-
1
&&
PyErr_Occurred
())
return
-
1
;
if
(
i
<
0
)
...
...
@@ -2818,7 +2818,7 @@ PyTypeObject PyListIter_Type = {
typedef
struct
{
PyObject_HEAD
long
it_index
;
Py_ssize_t
it_index
;
PyListObject
*
it_seq
;
/* Set to NULL when iterator is exhausted */
}
listreviterobject
;
...
...
@@ -2860,7 +2860,7 @@ static PyObject *
listreviter_next
(
listreviterobject
*
it
)
{
PyObject
*
item
;
long
index
=
it
->
it_index
;
Py_ssize_t
index
=
it
->
it_index
;
PyListObject
*
seq
=
it
->
it_seq
;
if
(
index
>=
0
&&
index
<
PyList_GET_SIZE
(
seq
))
{
...
...
Objects/methodobject.c
View file @
eb079f1c
...
...
@@ -65,7 +65,7 @@ PyCFunction_Call(PyObject *func, PyObject *arg, PyObject *kw)
PyCFunctionObject
*
f
=
(
PyCFunctionObject
*
)
func
;
PyCFunction
meth
=
PyCFunction_GET_FUNCTION
(
func
);
PyObject
*
self
=
PyCFunction_GET_SELF
(
func
);
long
size
;
Py_ssize_t
size
;
switch
(
PyCFunction_GET_FLAGS
(
func
)
&
~
(
METH_CLASS
|
METH_STATIC
|
METH_COEXIST
))
{
case
METH_VARARGS
:
...
...
@@ -81,7 +81,7 @@ PyCFunction_Call(PyObject *func, PyObject *arg, PyObject *kw)
if
(
size
==
0
)
return
(
*
meth
)(
self
,
NULL
);
PyErr_Format
(
PyExc_TypeError
,
"%.200s() takes no arguments (%
l
d given)"
,
"%.200s() takes no arguments (%
z
d given)"
,
f
->
m_ml
->
ml_name
,
size
);
return
NULL
;
}
...
...
@@ -92,7 +92,7 @@ PyCFunction_Call(PyObject *func, PyObject *arg, PyObject *kw)
if
(
size
==
1
)
return
(
*
meth
)(
self
,
PyTuple_GET_ITEM
(
arg
,
0
));
PyErr_Format
(
PyExc_TypeError
,
"%.200s() takes exactly one argument (%
l
d given)"
,
"%.200s() takes exactly one argument (%
z
d given)"
,
f
->
m_ml
->
ml_name
,
size
);
return
NULL
;
}
...
...
Objects/stringobject.c
View file @
eb079f1c
...
...
@@ -1030,7 +1030,7 @@ string_contains(PyObject *a, PyObject *el)
const
char
*
sub
=
PyString_AS_STRING
(
el
);
char
*
last
;
Py_ssize_t
len_sub
=
PyString_GET_SIZE
(
el
);
in
t
shortsub
;
Py_ssize_
t
shortsub
;
char
firstchar
,
lastchar
;
if
(
!
PyString_CheckExact
(
el
))
{
...
...
@@ -2942,11 +2942,11 @@ PyDoc_STRVAR(zfill__doc__,
static
PyObject
*
string_zfill
(
PyStringObject
*
self
,
PyObject
*
args
)
{
long
fill
;
Py_ssize_t
fill
;
PyObject
*
s
;
char
*
p
;
int
width
;
long
width
;
if
(
!
PyArg_ParseTuple
(
args
,
"l:zfill"
,
&
width
))
return
NULL
;
...
...
@@ -3886,7 +3886,7 @@ PyObject *
PyString_Format
(
PyObject
*
format
,
PyObject
*
args
)
{
char
*
fmt
,
*
res
;
in
t
arglen
,
argidx
;
Py_ssize_
t
arglen
,
argidx
;
Py_ssize_t
reslen
,
rescnt
,
fmtcnt
;
int
args_owned
=
0
;
PyObject
*
result
,
*
orig_args
;
...
...
@@ -4294,7 +4294,7 @@ PyString_Format(PyObject *format, PyObject *args)
/* Fiddle args right (remove the first argidx arguments) */
if
(
PyTuple_Check
(
orig_args
)
&&
argidx
>
0
)
{
PyObject
*
v
;
in
t
n
=
PyTuple_GET_SIZE
(
orig_args
)
-
argidx
;
Py_ssize_
t
n
=
PyTuple_GET_SIZE
(
orig_args
)
-
argidx
;
v
=
PyTuple_New
(
n
);
if
(
v
==
NULL
)
goto
error
;
...
...
Objects/structseq.c
View file @
eb079f1c
...
...
@@ -247,7 +247,7 @@ structseq_reduce(PyStructSequence* self)
PyObject
*
tup
;
PyObject
*
dict
;
PyObject
*
result
;
long
n_fields
,
n_visible_fields
,
n_unnamed_fields
;
Py_ssize_t
n_fields
,
n_visible_fields
,
n_unnamed_fields
;
int
i
;
n_fields
=
REAL_SIZE
(
self
);
...
...
Objects/tupleobject.c
View file @
eb079f1c
...
...
@@ -278,7 +278,8 @@ tuplehash(PyTupleObject *v)
if
(
y
==
-
1
)
return
-
1
;
x
=
(
x
^
y
)
*
mult
;
mult
+=
82520L
+
len
+
len
;
/* the cast might truncate len; that doesn't change hash stability */
mult
+=
(
long
)(
82520L
+
len
+
len
);
}
x
+=
97531L
;
if
(
x
==
-
1
)
...
...
@@ -850,10 +851,10 @@ tupleiter_next(tupleiterobject *it)
static
PyObject
*
tupleiter_len
(
tupleiterobject
*
it
)
{
long
len
=
0
;
Py_ssize_t
len
=
0
;
if
(
it
->
it_seq
)
len
=
PyTuple_GET_SIZE
(
it
->
it_seq
)
-
it
->
it_index
;
return
PyInt_From
Long
(
len
);
return
PyInt_From
Ssize_t
(
len
);
}
PyDoc_STRVAR
(
length_hint_doc
,
"Private method returning an estimate of len(list(it))."
);
...
...
Objects/typeobject.c
View file @
eb079f1c
...
...
@@ -1561,11 +1561,11 @@ valid_identifier(PyObject *s)
/* Replace Unicode objects in slots. */
static
PyObject
*
_unicode_to_string
(
PyObject
*
slots
,
in
t
nslots
)
_unicode_to_string
(
PyObject
*
slots
,
Py_ssize_
t
nslots
)
{
PyObject
*
tmp
=
slots
;
PyObject
*
o
,
*
o1
;
in
t
i
;
Py_ssize_
t
i
;
ssizessizeargfunc
copy
=
slots
->
ob_type
->
tp_as_sequence
->
sq_slice
;
for
(
i
=
0
;
i
<
nslots
;
i
++
)
{
if
(
PyUnicode_Check
(
o
=
PyTuple_GET_ITEM
(
tmp
,
i
)))
{
...
...
@@ -2428,7 +2428,7 @@ static int
same_slots_added
(
PyTypeObject
*
a
,
PyTypeObject
*
b
)
{
PyTypeObject
*
base
=
a
->
tp_base
;
in
t
size
;
Py_ssize_
t
size
;
if
(
base
!=
b
->
tp_base
)
return
0
;
...
...
@@ -2904,7 +2904,7 @@ add_getset(PyTypeObject *type, PyGetSetDef *gsp)
static
void
inherit_special
(
PyTypeObject
*
type
,
PyTypeObject
*
base
)
{
in
t
oldsize
,
newsize
;
Py_ssize_
t
oldsize
,
newsize
;
/* Special flag magic */
if
(
!
type
->
tp_as_buffer
&&
base
->
tp_as_buffer
)
{
...
...
@@ -3316,7 +3316,8 @@ PyType_Ready(PyTypeObject *type)
static
int
add_subclass
(
PyTypeObject
*
base
,
PyTypeObject
*
type
)
{
int
i
;
Py_ssize_t
i
;
int
result
;
PyObject
*
list
,
*
ref
,
*
new
;
list
=
base
->
tp_subclasses
;
...
...
@@ -3334,9 +3335,9 @@ add_subclass(PyTypeObject *base, PyTypeObject *type)
if
(
PyWeakref_GET_OBJECT
(
ref
)
==
Py_None
)
return
PyList_SetItem
(
list
,
i
,
new
);
}
i
=
PyList_Append
(
list
,
new
);
result
=
PyList_Append
(
list
,
new
);
Py_DECREF
(
new
);
return
i
;
return
result
;
}
static
void
...
...
@@ -4160,7 +4161,7 @@ slot_sq_item(PyObject *self, Py_ssize_t i)
return
NULL
;
}
}
ival
=
PyInt_From
Long
(
i
);
ival
=
PyInt_From
Ssize_t
(
i
);
if
(
ival
!=
NULL
)
{
args
=
PyTuple_New
(
1
);
if
(
args
!=
NULL
)
{
...
...
Objects/unicodeobject.c
View file @
eb079f1c
...
...
@@ -6541,7 +6541,7 @@ unicode_buffer_getsegcount(PyUnicodeObject *self,
return
1
;
}
static
in
t
static
Py_ssize_
t
unicode_buffer_getcharbuf
(
PyUnicodeObject
*
self
,
Py_ssize_t
index
,
const
void
**
ptr
)
...
...
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