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
d96ee909
Commit
d96ee909
authored
Feb 16, 2006
by
Martin v. Löwis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use Py_ssize_t to count the
parent
f5adf1eb
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
24 additions
and
22 deletions
+24
-22
Python/bltinmodule.c
Python/bltinmodule.c
+15
-15
Python/errors.c
Python/errors.c
+1
-1
Python/getargs.c
Python/getargs.c
+2
-2
Python/modsupport.c
Python/modsupport.c
+1
-1
Python/symtable.c
Python/symtable.c
+1
-1
Python/sysmodule.c
Python/sysmodule.c
+2
-1
Python/traceback.c
Python/traceback.c
+2
-1
No files found.
Python/bltinmodule.c
View file @
d96ee909
...
@@ -193,8 +193,8 @@ static PyObject *
...
@@ -193,8 +193,8 @@ static PyObject *
builtin_filter
(
PyObject
*
self
,
PyObject
*
args
)
builtin_filter
(
PyObject
*
self
,
PyObject
*
args
)
{
{
PyObject
*
func
,
*
seq
,
*
result
,
*
it
,
*
arg
;
PyObject
*
func
,
*
seq
,
*
result
,
*
it
,
*
arg
;
in
t
len
;
/* guess for result list size */
Py_ssize_
t
len
;
/* guess for result list size */
register
in
t
j
;
register
Py_ssize_
t
j
;
if
(
!
PyArg_UnpackTuple
(
args
,
"filter"
,
2
,
2
,
&
func
,
&
seq
))
if
(
!
PyArg_UnpackTuple
(
args
,
"filter"
,
2
,
2
,
&
func
,
&
seq
))
return
NULL
;
return
NULL
;
...
@@ -860,7 +860,7 @@ builtin_map(PyObject *self, PyObject *args)
...
@@ -860,7 +860,7 @@ builtin_map(PyObject *self, PyObject *args)
len
=
0
;
len
=
0
;
for
(
i
=
0
,
sqp
=
seqs
;
i
<
n
;
++
i
,
++
sqp
)
{
for
(
i
=
0
,
sqp
=
seqs
;
i
<
n
;
++
i
,
++
sqp
)
{
PyObject
*
curseq
;
PyObject
*
curseq
;
in
t
curlen
;
Py_ssize_
t
curlen
;
/* Get iterator. */
/* Get iterator. */
curseq
=
PyTuple_GetItem
(
args
,
i
+
1
);
curseq
=
PyTuple_GetItem
(
args
,
i
+
1
);
...
@@ -1338,7 +1338,7 @@ static PyObject *
...
@@ -1338,7 +1338,7 @@ static PyObject *
builtin_ord
(
PyObject
*
self
,
PyObject
*
obj
)
builtin_ord
(
PyObject
*
self
,
PyObject
*
obj
)
{
{
long
ord
;
long
ord
;
in
t
size
;
Py_ssize_
t
size
;
if
(
PyString_Check
(
obj
))
{
if
(
PyString_Check
(
obj
))
{
size
=
PyString_GET_SIZE
(
obj
);
size
=
PyString_GET_SIZE
(
obj
);
...
@@ -1363,7 +1363,7 @@ builtin_ord(PyObject *self, PyObject* obj)
...
@@ -1363,7 +1363,7 @@ builtin_ord(PyObject *self, PyObject* obj)
PyErr_Format
(
PyExc_TypeError
,
PyErr_Format
(
PyExc_TypeError
,
"ord() expected a character, "
"ord() expected a character, "
"but string of length %d found"
,
"but string of length %
z
d found"
,
size
);
size
);
return
NULL
;
return
NULL
;
}
}
...
@@ -2094,10 +2094,10 @@ static PyObject*
...
@@ -2094,10 +2094,10 @@ static PyObject*
builtin_zip
(
PyObject
*
self
,
PyObject
*
args
)
builtin_zip
(
PyObject
*
self
,
PyObject
*
args
)
{
{
PyObject
*
ret
;
PyObject
*
ret
;
const
in
t
itemsize
=
PySequence_Length
(
args
);
const
Py_ssize_
t
itemsize
=
PySequence_Length
(
args
);
in
t
i
;
Py_ssize_
t
i
;
PyObject
*
itlist
;
/* tuple of iterators */
PyObject
*
itlist
;
/* tuple of iterators */
in
t
len
;
/* guess at result length */
Py_ssize_
t
len
;
/* guess at result length */
if
(
itemsize
==
0
)
if
(
itemsize
==
0
)
return
PyList_New
(
0
);
return
PyList_New
(
0
);
...
@@ -2111,7 +2111,7 @@ builtin_zip(PyObject *self, PyObject *args)
...
@@ -2111,7 +2111,7 @@ builtin_zip(PyObject *self, PyObject *args)
len
=
-
1
;
/* unknown */
len
=
-
1
;
/* unknown */
for
(
i
=
0
;
i
<
itemsize
;
++
i
)
{
for
(
i
=
0
;
i
<
itemsize
;
++
i
)
{
PyObject
*
item
=
PyTuple_GET_ITEM
(
args
,
i
);
PyObject
*
item
=
PyTuple_GET_ITEM
(
args
,
i
);
in
t
thislen
=
_PyObject_LengthHint
(
item
);
Py_ssize_
t
thislen
=
_PyObject_LengthHint
(
item
);
if
(
thislen
<
0
)
{
if
(
thislen
<
0
)
{
if
(
!
PyErr_ExceptionMatches
(
PyExc_TypeError
)
&&
if
(
!
PyErr_ExceptionMatches
(
PyExc_TypeError
)
&&
!
PyErr_ExceptionMatches
(
PyExc_AttributeError
))
{
!
PyErr_ExceptionMatches
(
PyExc_AttributeError
))
{
...
@@ -2460,7 +2460,7 @@ filterstring(PyObject *func, PyObject *strobj)
...
@@ -2460,7 +2460,7 @@ filterstring(PyObject *func, PyObject *strobj)
Py_DECREF
(
good
);
Py_DECREF
(
good
);
}
}
if
(
ok
)
{
if
(
ok
)
{
in
t
reslen
;
Py_ssize_
t
reslen
;
if
(
!
PyString_Check
(
item
))
{
if
(
!
PyString_Check
(
item
))
{
PyErr_SetString
(
PyExc_TypeError
,
"can't filter str to str:"
PyErr_SetString
(
PyExc_TypeError
,
"can't filter str to str:"
" __getitem__ returned different type"
);
" __getitem__ returned different type"
);
...
@@ -2473,7 +2473,7 @@ filterstring(PyObject *func, PyObject *strobj)
...
@@ -2473,7 +2473,7 @@ filterstring(PyObject *func, PyObject *strobj)
PyString_AS_STRING
(
item
)[
0
];
PyString_AS_STRING
(
item
)[
0
];
}
else
{
}
else
{
/* do we need more space? */
/* do we need more space? */
in
t
need
=
j
+
reslen
+
len
-
i
-
1
;
Py_ssize_
t
need
=
j
+
reslen
+
len
-
i
-
1
;
if
(
need
>
outlen
)
{
if
(
need
>
outlen
)
{
/* overallocate, to avoid reallocations */
/* overallocate, to avoid reallocations */
if
(
need
<
2
*
outlen
)
if
(
need
<
2
*
outlen
)
...
@@ -2513,8 +2513,8 @@ filterunicode(PyObject *func, PyObject *strobj)
...
@@ -2513,8 +2513,8 @@ filterunicode(PyObject *func, PyObject *strobj)
{
{
PyObject
*
result
;
PyObject
*
result
;
register
int
i
,
j
;
register
int
i
,
j
;
in
t
len
=
PyUnicode_GetSize
(
strobj
);
Py_ssize_
t
len
=
PyUnicode_GetSize
(
strobj
);
in
t
outlen
=
len
;
Py_ssize_
t
outlen
=
len
;
if
(
func
==
Py_None
)
{
if
(
func
==
Py_None
)
{
/* If it's a real string we can return the original,
/* If it's a real string we can return the original,
...
@@ -2554,7 +2554,7 @@ filterunicode(PyObject *func, PyObject *strobj)
...
@@ -2554,7 +2554,7 @@ filterunicode(PyObject *func, PyObject *strobj)
Py_DECREF
(
good
);
Py_DECREF
(
good
);
}
}
if
(
ok
)
{
if
(
ok
)
{
in
t
reslen
;
Py_ssize_
t
reslen
;
if
(
!
PyUnicode_Check
(
item
))
{
if
(
!
PyUnicode_Check
(
item
))
{
PyErr_SetString
(
PyExc_TypeError
,
PyErr_SetString
(
PyExc_TypeError
,
"can't filter unicode to unicode:"
"can't filter unicode to unicode:"
...
@@ -2568,7 +2568,7 @@ filterunicode(PyObject *func, PyObject *strobj)
...
@@ -2568,7 +2568,7 @@ filterunicode(PyObject *func, PyObject *strobj)
PyUnicode_AS_UNICODE
(
item
)[
0
];
PyUnicode_AS_UNICODE
(
item
)[
0
];
else
{
else
{
/* do we need more space? */
/* do we need more space? */
in
t
need
=
j
+
reslen
+
len
-
i
-
1
;
Py_ssize_
t
need
=
j
+
reslen
+
len
-
i
-
1
;
if
(
need
>
outlen
)
{
if
(
need
>
outlen
)
{
/* overallocate,
/* overallocate,
to avoid reallocations */
to avoid reallocations */
...
...
Python/errors.c
View file @
d96ee909
...
@@ -83,7 +83,7 @@ PyErr_GivenExceptionMatches(PyObject *err, PyObject *exc)
...
@@ -83,7 +83,7 @@ PyErr_GivenExceptionMatches(PyObject *err, PyObject *exc)
return
0
;
return
0
;
}
}
if
(
PyTuple_Check
(
exc
))
{
if
(
PyTuple_Check
(
exc
))
{
in
t
i
,
n
;
Py_ssize_
t
i
,
n
;
n
=
PyTuple_Size
(
exc
);
n
=
PyTuple_Size
(
exc
);
for
(
i
=
0
;
i
<
n
;
i
++
)
{
for
(
i
=
0
;
i
<
n
;
i
++
)
{
/* Test recursively */
/* Test recursively */
...
...
Python/getargs.c
View file @
d96ee909
...
@@ -153,7 +153,7 @@ cleanreturn(int retval, PyObject *freelist)
...
@@ -153,7 +153,7 @@ cleanreturn(int retval, PyObject *freelist)
{
{
if
(
freelist
)
{
if
(
freelist
)
{
if
((
retval
)
==
0
)
{
if
((
retval
)
==
0
)
{
in
t
len
=
PyList_GET_SIZE
(
freelist
),
i
;
Py_ssize_
t
len
=
PyList_GET_SIZE
(
freelist
),
i
;
for
(
i
=
0
;
i
<
len
;
i
++
)
for
(
i
=
0
;
i
<
len
;
i
++
)
PyMem_FREE
(
PyCObject_AsVoidPtr
(
PyMem_FREE
(
PyCObject_AsVoidPtr
(
PyList_GET_ITEM
(
freelist
,
i
)));
PyList_GET_ITEM
(
freelist
,
i
)));
...
@@ -176,7 +176,7 @@ vgetargs1(PyObject *args, const char *format, va_list *p_va, int flags)
...
@@ -176,7 +176,7 @@ vgetargs1(PyObject *args, const char *format, va_list *p_va, int flags)
int
level
=
0
;
int
level
=
0
;
int
endfmt
=
0
;
int
endfmt
=
0
;
const
char
*
formatsave
=
format
;
const
char
*
formatsave
=
format
;
in
t
i
,
len
;
Py_ssize_
t
i
,
len
;
char
*
msg
;
char
*
msg
;
PyObject
*
freelist
=
NULL
;
PyObject
*
freelist
=
NULL
;
int
compat
=
flags
&
FLAG_COMPAT
;
int
compat
=
flags
&
FLAG_COMPAT
;
...
...
Python/modsupport.c
View file @
d96ee909
...
@@ -315,7 +315,7 @@ do_mkvalue(const char **p_format, va_list *p_va)
...
@@ -315,7 +315,7 @@ do_mkvalue(const char **p_format, va_list *p_va)
case
'n'
:
case
'n'
:
#if SIZEOF_SIZE_T!=SIZEOF_LONG
#if SIZEOF_SIZE_T!=SIZEOF_LONG
return
Py
Long_FromSsize_t
(
va_arg
(
*
p_va
,
Py_S
size_t
));
return
Py
Int_FromSsize_t
(
va_arg
(
*
p_va
,
Py_s
size_t
));
#endif
#endif
/* Fall through from 'n' to 'l' if Py_ssize_t is long */
/* Fall through from 'n' to 'l' if Py_ssize_t is long */
case
'l'
:
case
'l'
:
...
...
Python/symtable.c
View file @
d96ee909
...
@@ -715,7 +715,7 @@ symtable_warn(struct symtable *st, char *msg, int lineno)
...
@@ -715,7 +715,7 @@ symtable_warn(struct symtable *st, char *msg, int lineno)
static
int
static
int
symtable_exit_block
(
struct
symtable
*
st
,
void
*
ast
)
symtable_exit_block
(
struct
symtable
*
st
,
void
*
ast
)
{
{
in
t
end
;
Py_ssize_
t
end
;
Py_DECREF
(
st
->
st_cur
);
Py_DECREF
(
st
->
st_cur
);
end
=
PyList_GET_SIZE
(
st
->
st_stack
)
-
1
;
end
=
PyList_GET_SIZE
(
st
->
st_stack
)
-
1
;
...
...
Python/sysmodule.c
View file @
d96ee909
...
@@ -947,7 +947,8 @@ static void
...
@@ -947,7 +947,8 @@ static void
svnversion_init
(
void
)
svnversion_init
(
void
)
{
{
const
char
*
python
,
*
br_start
,
*
br_end
,
*
br_end2
,
*
svnversion
;
const
char
*
python
,
*
br_start
,
*
br_end
,
*
br_end2
,
*
svnversion
;
int
len
,
istag
;
Py_ssize_t
len
;
int
istag
;
if
(
svn_initialized
)
if
(
svn_initialized
)
return
;
return
;
...
...
Python/traceback.c
View file @
d96ee909
...
@@ -153,7 +153,8 @@ tb_displayline(PyObject *f, char *filename, int lineno, char *name)
...
@@ -153,7 +153,8 @@ tb_displayline(PyObject *f, char *filename, int lineno, char *name)
tail
++
;
tail
++
;
path
=
PySys_GetObject
(
"path"
);
path
=
PySys_GetObject
(
"path"
);
if
(
path
!=
NULL
&&
PyList_Check
(
path
))
{
if
(
path
!=
NULL
&&
PyList_Check
(
path
))
{
int
npath
=
PyList_Size
(
path
);
Py_ssize_t
_npath
=
PyList_Size
(
path
);
int
npath
=
Py_SAFE_DOWNCAST
(
_npath
,
Py_ssize_t
,
int
);
size_t
taillen
=
strlen
(
tail
);
size_t
taillen
=
strlen
(
tail
);
char
namebuf
[
MAXPATHLEN
+
1
];
char
namebuf
[
MAXPATHLEN
+
1
];
for
(
i
=
0
;
i
<
npath
;
i
++
)
{
for
(
i
=
0
;
i
<
npath
;
i
++
)
{
...
...
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