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
452728f8
Commit
452728f8
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.
parent
c1b0566f
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
67 additions
and
66 deletions
+67
-66
Modules/_bisectmodule.c
Modules/_bisectmodule.c
+2
-2
Modules/_heapqmodule.c
Modules/_heapqmodule.c
+13
-11
Modules/arraymodule.c
Modules/arraymodule.c
+13
-16
Modules/cStringIO.c
Modules/cStringIO.c
+3
-3
Modules/collectionsmodule.c
Modules/collectionsmodule.c
+1
-1
Modules/itertoolsmodule.c
Modules/itertoolsmodule.c
+8
-8
Modules/mmapmodule.c
Modules/mmapmodule.c
+8
-8
Modules/operator.c
Modules/operator.c
+6
-6
Modules/parsermodule.c
Modules/parsermodule.c
+1
-1
Modules/stropmodule.c
Modules/stropmodule.c
+5
-4
Modules/structmodule.c
Modules/structmodule.c
+5
-4
Modules/zipimport.c
Modules/zipimport.c
+2
-2
No files found.
Modules/_bisectmodule.c
View file @
452728f8
...
@@ -6,10 +6,10 @@ Converted to C by Dmitry Vasiliev (dima at hlabs.spb.ru).
...
@@ -6,10 +6,10 @@ Converted to C by Dmitry Vasiliev (dima at hlabs.spb.ru).
#include "Python.h"
#include "Python.h"
static
int
static
int
internal_bisect_right
(
PyObject
*
list
,
PyObject
*
item
,
int
lo
,
in
t
hi
)
internal_bisect_right
(
PyObject
*
list
,
PyObject
*
item
,
Py_ssize_t
lo
,
Py_ssize_
t
hi
)
{
{
PyObject
*
litem
;
PyObject
*
litem
;
in
t
mid
,
res
;
Py_ssize_
t
mid
,
res
;
if
(
hi
==
-
1
)
{
if
(
hi
==
-
1
)
{
hi
=
PySequence_Size
(
list
);
hi
=
PySequence_Size
(
list
);
...
...
Modules/_heapqmodule.c
View file @
452728f8
...
@@ -9,10 +9,11 @@ annotated by Fran
...
@@ -9,10 +9,11 @@ annotated by Fran
#include "Python.h"
#include "Python.h"
static
int
static
int
_siftdown
(
PyListObject
*
heap
,
int
startpos
,
in
t
pos
)
_siftdown
(
PyListObject
*
heap
,
Py_ssize_t
startpos
,
Py_ssize_
t
pos
)
{
{
PyObject
*
newitem
,
*
parent
;
PyObject
*
newitem
,
*
parent
;
int
cmp
,
parentpos
;
int
cmp
;
Py_ssize_t
parentpos
;
assert
(
PyList_Check
(
heap
));
assert
(
PyList_Check
(
heap
));
if
(
pos
>=
PyList_GET_SIZE
(
heap
))
{
if
(
pos
>=
PyList_GET_SIZE
(
heap
))
{
...
@@ -45,9 +46,9 @@ _siftdown(PyListObject *heap, int startpos, int pos)
...
@@ -45,9 +46,9 @@ _siftdown(PyListObject *heap, int startpos, int pos)
}
}
static
int
static
int
_siftup
(
PyListObject
*
heap
,
in
t
pos
)
_siftup
(
PyListObject
*
heap
,
Py_ssize_
t
pos
)
{
{
in
t
startpos
,
endpos
,
childpos
,
rightpos
;
Py_ssize_
t
startpos
,
endpos
,
childpos
,
rightpos
;
int
cmp
;
int
cmp
;
PyObject
*
newitem
,
*
tmp
;
PyObject
*
newitem
,
*
tmp
;
...
@@ -123,7 +124,7 @@ static PyObject *
...
@@ -123,7 +124,7 @@ static PyObject *
heappop
(
PyObject
*
self
,
PyObject
*
heap
)
heappop
(
PyObject
*
self
,
PyObject
*
heap
)
{
{
PyObject
*
lastelt
,
*
returnitem
;
PyObject
*
lastelt
,
*
returnitem
;
in
t
n
;
Py_ssize_
t
n
;
if
(
!
PyList_Check
(
heap
))
{
if
(
!
PyList_Check
(
heap
))
{
PyErr_SetString
(
PyExc_TypeError
,
"heap argument must be a list"
);
PyErr_SetString
(
PyExc_TypeError
,
"heap argument must be a list"
);
...
@@ -197,7 +198,7 @@ this routine unless written as part of a conditional replacement:\n\n\
...
@@ -197,7 +198,7 @@ this routine unless written as part of a conditional replacement:\n\n\
static
PyObject
*
static
PyObject
*
heapify
(
PyObject
*
self
,
PyObject
*
heap
)
heapify
(
PyObject
*
self
,
PyObject
*
heap
)
{
{
in
t
i
,
n
;
Py_ssize_
t
i
,
n
;
if
(
!
PyList_Check
(
heap
))
{
if
(
!
PyList_Check
(
heap
))
{
PyErr_SetString
(
PyExc_TypeError
,
"heap argument must be a list"
);
PyErr_SetString
(
PyExc_TypeError
,
"heap argument must be a list"
);
...
@@ -300,10 +301,11 @@ PyDoc_STRVAR(nlargest_doc,
...
@@ -300,10 +301,11 @@ PyDoc_STRVAR(nlargest_doc,
Equivalent to: sorted(iterable, reverse=True)[:n]
\n
"
);
Equivalent to: sorted(iterable, reverse=True)[:n]
\n
"
);
static
int
static
int
_siftdownmax
(
PyListObject
*
heap
,
int
startpos
,
in
t
pos
)
_siftdownmax
(
PyListObject
*
heap
,
Py_ssize_t
startpos
,
Py_ssize_
t
pos
)
{
{
PyObject
*
newitem
,
*
parent
;
PyObject
*
newitem
,
*
parent
;
int
cmp
,
parentpos
;
int
cmp
;
Py_ssize_t
parentpos
;
assert
(
PyList_Check
(
heap
));
assert
(
PyList_Check
(
heap
));
if
(
pos
>=
PyList_GET_SIZE
(
heap
))
{
if
(
pos
>=
PyList_GET_SIZE
(
heap
))
{
...
@@ -336,9 +338,9 @@ _siftdownmax(PyListObject *heap, int startpos, int pos)
...
@@ -336,9 +338,9 @@ _siftdownmax(PyListObject *heap, int startpos, int pos)
}
}
static
int
static
int
_siftupmax
(
PyListObject
*
heap
,
in
t
pos
)
_siftupmax
(
PyListObject
*
heap
,
Py_ssize_
t
pos
)
{
{
in
t
startpos
,
endpos
,
childpos
,
rightpos
;
Py_ssize_
t
startpos
,
endpos
,
childpos
,
rightpos
;
int
cmp
;
int
cmp
;
PyObject
*
newitem
,
*
tmp
;
PyObject
*
newitem
,
*
tmp
;
...
@@ -389,7 +391,7 @@ static PyObject *
...
@@ -389,7 +391,7 @@ static PyObject *
nsmallest
(
PyObject
*
self
,
PyObject
*
args
)
nsmallest
(
PyObject
*
self
,
PyObject
*
args
)
{
{
PyObject
*
heap
=
NULL
,
*
elem
,
*
iterable
,
*
los
,
*
it
,
*
oldelem
;
PyObject
*
heap
=
NULL
,
*
elem
,
*
iterable
,
*
los
,
*
it
,
*
oldelem
;
in
t
i
,
n
;
Py_ssize_
t
i
,
n
;
if
(
!
PyArg_ParseTuple
(
args
,
"iO:nsmallest"
,
&
n
,
&
iterable
))
if
(
!
PyArg_ParseTuple
(
args
,
"iO:nsmallest"
,
&
n
,
&
iterable
))
return
NULL
;
return
NULL
;
...
...
Modules/arraymodule.c
View file @
452728f8
...
@@ -688,11 +688,11 @@ array_repeat(arrayobject *a, Py_ssize_t n)
...
@@ -688,11 +688,11 @@ array_repeat(arrayobject *a, Py_ssize_t n)
}
}
static
int
static
int
array_ass_slice
(
arrayobject
*
a
,
int
ilow
,
in
t
ihigh
,
PyObject
*
v
)
array_ass_slice
(
arrayobject
*
a
,
Py_ssize_t
ilow
,
Py_ssize_
t
ihigh
,
PyObject
*
v
)
{
{
char
*
item
;
char
*
item
;
in
t
n
;
/* Size of replacement array */
Py_ssize_
t
n
;
/* Size of replacement array */
in
t
d
;
/* Change in size */
Py_ssize_
t
d
;
/* Change in size */
#define b ((arrayobject *)v)
#define b ((arrayobject *)v)
if
(
v
==
NULL
)
if
(
v
==
NULL
)
n
=
0
;
n
=
0
;
...
@@ -907,10 +907,7 @@ array_count(arrayobject *self, PyObject *v)
...
@@ -907,10 +907,7 @@ array_count(arrayobject *self, PyObject *v)
else
if
(
cmp
<
0
)
else
if
(
cmp
<
0
)
return
NULL
;
return
NULL
;
}
}
if
(
i
<
LONG_MAX
)
return
PyInt_FromSsize_t
(
count
);
return
PyInt_FromLong
((
long
)
count
);
else
return
PyLong_FromLong
(
count
);
}
}
PyDoc_STRVAR
(
count_doc
,
PyDoc_STRVAR
(
count_doc
,
...
@@ -987,9 +984,9 @@ Remove the first occurence of x in the array.");
...
@@ -987,9 +984,9 @@ Remove the first occurence of x in the array.");
static
PyObject
*
static
PyObject
*
array_pop
(
arrayobject
*
self
,
PyObject
*
args
)
array_pop
(
arrayobject
*
self
,
PyObject
*
args
)
{
{
in
t
i
=
-
1
;
Py_ssize_
t
i
=
-
1
;
PyObject
*
v
;
PyObject
*
v
;
if
(
!
PyArg_ParseTuple
(
args
,
"|
i
:pop"
,
&
i
))
if
(
!
PyArg_ParseTuple
(
args
,
"|
n
:pop"
,
&
i
))
return
NULL
;
return
NULL
;
if
(
self
->
ob_size
==
0
)
{
if
(
self
->
ob_size
==
0
)
{
/* Special-case most common failure cause */
/* Special-case most common failure cause */
...
@@ -1196,7 +1193,7 @@ static PyObject *
...
@@ -1196,7 +1193,7 @@ static PyObject *
array_fromfile
(
arrayobject
*
self
,
PyObject
*
args
)
array_fromfile
(
arrayobject
*
self
,
PyObject
*
args
)
{
{
PyObject
*
f
;
PyObject
*
f
;
in
t
n
;
Py_ssize_
t
n
;
FILE
*
fp
;
FILE
*
fp
;
if
(
!
PyArg_ParseTuple
(
args
,
"Oi:fromfile"
,
&
f
,
&
n
))
if
(
!
PyArg_ParseTuple
(
args
,
"Oi:fromfile"
,
&
f
,
&
n
))
return
NULL
;
return
NULL
;
...
@@ -1207,9 +1204,9 @@ array_fromfile(arrayobject *self, PyObject *args)
...
@@ -1207,9 +1204,9 @@ array_fromfile(arrayobject *self, PyObject *args)
}
}
if
(
n
>
0
)
{
if
(
n
>
0
)
{
char
*
item
=
self
->
ob_item
;
char
*
item
=
self
->
ob_item
;
in
t
itemsize
=
self
->
ob_descr
->
itemsize
;
Py_ssize_
t
itemsize
=
self
->
ob_descr
->
itemsize
;
size_t
nread
;
size_t
nread
;
in
t
newlength
;
Py_ssize_
t
newlength
;
size_t
newbytes
;
size_t
newbytes
;
/* Be careful here about overflow */
/* Be careful here about overflow */
if
((
newlength
=
self
->
ob_size
+
n
)
<=
0
||
if
((
newlength
=
self
->
ob_size
+
n
)
<=
0
||
...
@@ -1577,13 +1574,13 @@ static PyObject*
...
@@ -1577,13 +1574,13 @@ static PyObject*
array_subscr
(
arrayobject
*
self
,
PyObject
*
item
)
array_subscr
(
arrayobject
*
self
,
PyObject
*
item
)
{
{
if
(
PyInt_Check
(
item
))
{
if
(
PyInt_Check
(
item
))
{
long
i
=
PyInt_AS_LONG
(
item
);
Py_ssize_t
i
=
PyInt_AS_LONG
(
item
);
if
(
i
<
0
)
if
(
i
<
0
)
i
+=
self
->
ob_size
;
i
+=
self
->
ob_size
;
return
array_item
(
self
,
i
);
return
array_item
(
self
,
i
);
}
}
else
if
(
PyLong_Check
(
item
))
{
else
if
(
PyLong_Check
(
item
))
{
long
i
=
PyLong_AsLong
(
item
);
Py_ssize_t
i
=
PyInt_AsSsize_t
(
item
);
if
(
i
==
-
1
&&
PyErr_Occurred
())
if
(
i
==
-
1
&&
PyErr_Occurred
())
return
NULL
;
return
NULL
;
if
(
i
<
0
)
if
(
i
<
0
)
...
@@ -1631,13 +1628,13 @@ static int
...
@@ -1631,13 +1628,13 @@ static int
array_ass_subscr
(
arrayobject
*
self
,
PyObject
*
item
,
PyObject
*
value
)
array_ass_subscr
(
arrayobject
*
self
,
PyObject
*
item
,
PyObject
*
value
)
{
{
if
(
PyInt_Check
(
item
))
{
if
(
PyInt_Check
(
item
))
{
long
i
=
PyInt_AS_LONG
(
item
);
Py_ssize_t
i
=
PyInt_AS_LONG
(
item
);
if
(
i
<
0
)
if
(
i
<
0
)
i
+=
self
->
ob_size
;
i
+=
self
->
ob_size
;
return
array_ass_item
(
self
,
i
,
value
);
return
array_ass_item
(
self
,
i
,
value
);
}
}
else
if
(
PyLong_Check
(
item
))
{
else
if
(
PyLong_Check
(
item
))
{
long
i
=
PyLong_AsLong
(
item
);
Py_ssize_t
i
=
PyInt_AsSsize_t
(
item
);
if
(
i
==
-
1
&&
PyErr_Occurred
())
if
(
i
==
-
1
&&
PyErr_Occurred
())
return
-
1
;
return
-
1
;
if
(
i
<
0
)
if
(
i
<
0
)
...
...
Modules/cStringIO.c
View file @
452728f8
...
@@ -129,7 +129,7 @@ IO_cgetval(PyObject *self) {
...
@@ -129,7 +129,7 @@ IO_cgetval(PyObject *self) {
static
PyObject
*
static
PyObject
*
IO_getval
(
IOobject
*
self
,
PyObject
*
args
)
{
IO_getval
(
IOobject
*
self
,
PyObject
*
args
)
{
PyObject
*
use_pos
=
Py_None
;
PyObject
*
use_pos
=
Py_None
;
in
t
s
;
Py_ssize_
t
s
;
UNLESS
(
IO__opencheck
(
self
))
return
NULL
;
UNLESS
(
IO__opencheck
(
self
))
return
NULL
;
UNLESS
(
PyArg_UnpackTuple
(
args
,
"getval"
,
0
,
1
,
&
use_pos
))
return
NULL
;
UNLESS
(
PyArg_UnpackTuple
(
args
,
"getval"
,
0
,
1
,
&
use_pos
))
return
NULL
;
...
@@ -156,7 +156,7 @@ PyDoc_STRVAR(IO_read__doc__,
...
@@ -156,7 +156,7 @@ PyDoc_STRVAR(IO_read__doc__,
static
int
static
int
IO_cread
(
PyObject
*
self
,
char
**
output
,
Py_ssize_t
n
)
{
IO_cread
(
PyObject
*
self
,
char
**
output
,
Py_ssize_t
n
)
{
in
t
l
;
Py_ssize_
t
l
;
UNLESS
(
IO__opencheck
(
IOOOBJECT
(
self
)))
return
-
1
;
UNLESS
(
IO__opencheck
(
IOOOBJECT
(
self
)))
return
-
1
;
l
=
((
IOobject
*
)
self
)
->
string_size
-
((
IOobject
*
)
self
)
->
pos
;
l
=
((
IOobject
*
)
self
)
->
string_size
-
((
IOobject
*
)
self
)
->
pos
;
...
@@ -279,7 +279,7 @@ IO_tell(IOobject *self, PyObject *unused) {
...
@@ -279,7 +279,7 @@ IO_tell(IOobject *self, PyObject *unused) {
UNLESS
(
IO__opencheck
(
self
))
return
NULL
;
UNLESS
(
IO__opencheck
(
self
))
return
NULL
;
return
PyInt_From
Long
(
self
->
pos
);
return
PyInt_From
Ssize_t
(
self
->
pos
);
}
}
PyDoc_STRVAR
(
IO_truncate__doc__
,
PyDoc_STRVAR
(
IO_truncate__doc__
,
...
...
Modules/collectionsmodule.c
View file @
452728f8
...
@@ -489,7 +489,7 @@ deque_ass_item(dequeobject *deque, Py_ssize_t i, PyObject *v)
...
@@ -489,7 +489,7 @@ deque_ass_item(dequeobject *deque, Py_ssize_t i, PyObject *v)
{
{
PyObject
*
old_value
;
PyObject
*
old_value
;
block
*
b
;
block
*
b
;
in
t
n
,
len
=
deque
->
len
,
halflen
=
(
len
+
1
)
>>
1
,
index
=
i
;
Py_ssize_
t
n
,
len
=
deque
->
len
,
halflen
=
(
len
+
1
)
>>
1
,
index
=
i
;
if
(
i
<
0
||
i
>=
len
)
{
if
(
i
<
0
||
i
>=
len
)
{
PyErr_SetString
(
PyExc_IndexError
,
PyErr_SetString
(
PyExc_IndexError
,
...
...
Modules/itertoolsmodule.c
View file @
452728f8
...
@@ -1054,7 +1054,7 @@ islice_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
...
@@ -1054,7 +1054,7 @@ islice_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
PyObject
*
seq
;
PyObject
*
seq
;
long
start
=
0
,
stop
=-
1
,
step
=
1
;
long
start
=
0
,
stop
=-
1
,
step
=
1
;
PyObject
*
it
,
*
a1
=
NULL
,
*
a2
=
NULL
,
*
a3
=
NULL
;
PyObject
*
it
,
*
a1
=
NULL
,
*
a2
=
NULL
,
*
a3
=
NULL
;
in
t
numargs
;
Py_ssize_
t
numargs
;
isliceobject
*
lz
;
isliceobject
*
lz
;
if
(
!
_PyArg_NoKeywords
(
"islice()"
,
kwds
))
if
(
!
_PyArg_NoKeywords
(
"islice()"
,
kwds
))
...
@@ -1378,7 +1378,7 @@ imap_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
...
@@ -1378,7 +1378,7 @@ imap_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
{
PyObject
*
it
,
*
iters
,
*
func
;
PyObject
*
it
,
*
iters
,
*
func
;
imapobject
*
lz
;
imapobject
*
lz
;
in
t
numargs
,
i
;
Py_ssize_
t
numargs
,
i
;
if
(
!
_PyArg_NoKeywords
(
"imap()"
,
kwds
))
if
(
!
_PyArg_NoKeywords
(
"imap()"
,
kwds
))
return
NULL
;
return
NULL
;
...
@@ -1466,7 +1466,7 @@ imap_next(imapobject *lz)
...
@@ -1466,7 +1466,7 @@ imap_next(imapobject *lz)
PyObject
*
val
;
PyObject
*
val
;
PyObject
*
argtuple
;
PyObject
*
argtuple
;
PyObject
*
result
;
PyObject
*
result
;
in
t
numargs
,
i
;
Py_ssize_
t
numargs
,
i
;
numargs
=
PyTuple_Size
(
lz
->
iters
);
numargs
=
PyTuple_Size
(
lz
->
iters
);
argtuple
=
PyTuple_New
(
numargs
);
argtuple
=
PyTuple_New
(
numargs
);
...
@@ -1547,7 +1547,7 @@ static PyTypeObject imap_type = {
...
@@ -1547,7 +1547,7 @@ static PyTypeObject imap_type = {
typedef
struct
{
typedef
struct
{
PyObject_HEAD
PyObject_HEAD
long
tuplesize
;
Py_ssize_t
tuplesize
;
long
iternum
;
/* which iterator is active */
long
iternum
;
/* which iterator is active */
PyObject
*
ittuple
;
/* tuple of iterators */
PyObject
*
ittuple
;
/* tuple of iterators */
}
chainobject
;
}
chainobject
;
...
@@ -1558,7 +1558,7 @@ static PyObject *
...
@@ -1558,7 +1558,7 @@ static PyObject *
chain_new
(
PyTypeObject
*
type
,
PyObject
*
args
,
PyObject
*
kwds
)
chain_new
(
PyTypeObject
*
type
,
PyObject
*
args
,
PyObject
*
kwds
)
{
{
chainobject
*
lz
;
chainobject
*
lz
;
in
t
tuplesize
=
PySequence_Length
(
args
);
Py_ssize_
t
tuplesize
=
PySequence_Length
(
args
);
int
i
;
int
i
;
PyObject
*
ittuple
;
PyObject
*
ittuple
;
...
@@ -2074,7 +2074,7 @@ static PyTypeObject count_type = {
...
@@ -2074,7 +2074,7 @@ static PyTypeObject count_type = {
typedef
struct
{
typedef
struct
{
PyObject_HEAD
PyObject_HEAD
long
tuplesize
;
Py_ssize_t
tuplesize
;
PyObject
*
ittuple
;
/* tuple of iterators */
PyObject
*
ittuple
;
/* tuple of iterators */
PyObject
*
result
;
PyObject
*
result
;
}
izipobject
;
}
izipobject
;
...
@@ -2088,7 +2088,7 @@ izip_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
...
@@ -2088,7 +2088,7 @@ izip_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
int
i
;
int
i
;
PyObject
*
ittuple
;
/* tuple of iterators */
PyObject
*
ittuple
;
/* tuple of iterators */
PyObject
*
result
;
PyObject
*
result
;
in
t
tuplesize
=
PySequence_Length
(
args
);
Py_ssize_
t
tuplesize
=
PySequence_Length
(
args
);
if
(
!
_PyArg_NoKeywords
(
"izip()"
,
kwds
))
if
(
!
_PyArg_NoKeywords
(
"izip()"
,
kwds
))
return
NULL
;
return
NULL
;
...
@@ -2160,7 +2160,7 @@ static PyObject *
...
@@ -2160,7 +2160,7 @@ static PyObject *
izip_next
(
izipobject
*
lz
)
izip_next
(
izipobject
*
lz
)
{
{
int
i
;
int
i
;
long
tuplesize
=
lz
->
tuplesize
;
Py_ssize_t
tuplesize
=
lz
->
tuplesize
;
PyObject
*
result
=
lz
->
result
;
PyObject
*
result
=
lz
->
result
;
PyObject
*
it
;
PyObject
*
it
;
PyObject
*
item
;
PyObject
*
item
;
...
...
Modules/mmapmodule.c
View file @
452728f8
...
@@ -220,11 +220,11 @@ static PyObject *
...
@@ -220,11 +220,11 @@ static PyObject *
mmap_read_method
(
mmap_object
*
self
,
mmap_read_method
(
mmap_object
*
self
,
PyObject
*
args
)
PyObject
*
args
)
{
{
long
num_bytes
;
Py_ssize_t
num_bytes
;
PyObject
*
result
;
PyObject
*
result
;
CHECK_VALID
(
NULL
);
CHECK_VALID
(
NULL
);
if
(
!
PyArg_ParseTuple
(
args
,
"
l
:read"
,
&
num_bytes
))
if
(
!
PyArg_ParseTuple
(
args
,
"
n
:read"
,
&
num_bytes
))
return
(
NULL
);
return
(
NULL
);
/* silently 'adjust' out-of-range requests */
/* silently 'adjust' out-of-range requests */
...
@@ -240,7 +240,7 @@ static PyObject *
...
@@ -240,7 +240,7 @@ static PyObject *
mmap_find_method
(
mmap_object
*
self
,
mmap_find_method
(
mmap_object
*
self
,
PyObject
*
args
)
PyObject
*
args
)
{
{
long
start
=
self
->
pos
;
Py_ssize_t
start
=
self
->
pos
;
char
*
needle
;
char
*
needle
;
int
len
;
int
len
;
...
@@ -468,10 +468,10 @@ mmap_tell_method(mmap_object *self, PyObject *args)
...
@@ -468,10 +468,10 @@ mmap_tell_method(mmap_object *self, PyObject *args)
static
PyObject
*
static
PyObject
*
mmap_flush_method
(
mmap_object
*
self
,
PyObject
*
args
)
mmap_flush_method
(
mmap_object
*
self
,
PyObject
*
args
)
{
{
unsigned
long
offset
=
0
;
Py_ssize_t
offset
=
0
;
unsigned
long
size
=
self
->
size
;
Py_ssize_t
size
=
self
->
size
;
CHECK_VALID
(
NULL
);
CHECK_VALID
(
NULL
);
if
(
!
PyArg_ParseTuple
(
args
,
"|
kk
:flush"
,
&
offset
,
&
size
))
{
if
(
!
PyArg_ParseTuple
(
args
,
"|
nn
:flush"
,
&
offset
,
&
size
))
{
return
NULL
;
return
NULL
;
}
else
if
((
offset
+
size
)
>
self
->
size
)
{
}
else
if
((
offset
+
size
)
>
self
->
size
)
{
PyErr_SetString
(
PyExc_ValueError
,
PyErr_SetString
(
PyExc_ValueError
,
...
@@ -1092,8 +1092,8 @@ new_mmap_object(PyObject *self, PyObject *args, PyObject *kwdict)
...
@@ -1092,8 +1092,8 @@ new_mmap_object(PyObject *self, PyObject *args, PyObject *kwdict)
m_obj
->
map_handle
=
CreateFileMapping
(
m_obj
->
file_handle
,
m_obj
->
map_handle
=
CreateFileMapping
(
m_obj
->
file_handle
,
NULL
,
NULL
,
flProtect
,
flProtect
,
0
,
(
DWORD
)(
m_obj
->
size
>>
32
)
,
m_obj
->
size
,
(
DWORD
)(
m_obj
->
size
&
0xFFFFFFFF
)
,
m_obj
->
tagname
);
m_obj
->
tagname
);
if
(
m_obj
->
map_handle
!=
NULL
)
{
if
(
m_obj
->
map_handle
!=
NULL
)
{
m_obj
->
data
=
(
char
*
)
MapViewOfFile
(
m_obj
->
map_handle
,
m_obj
->
data
=
(
char
*
)
MapViewOfFile
(
m_obj
->
map_handle
,
...
...
Modules/operator.c
View file @
452728f8
...
@@ -296,7 +296,7 @@ spam2(ge,__ge__, "ge(a, b) -- Same as a>=b.")
...
@@ -296,7 +296,7 @@ spam2(ge,__ge__, "ge(a, b) -- Same as a>=b.")
typedef
struct
{
typedef
struct
{
PyObject_HEAD
PyObject_HEAD
in
t
nitems
;
Py_ssize_
t
nitems
;
PyObject
*
item
;
PyObject
*
item
;
}
itemgetterobject
;
}
itemgetterobject
;
...
@@ -307,7 +307,7 @@ itemgetter_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
...
@@ -307,7 +307,7 @@ itemgetter_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
{
itemgetterobject
*
ig
;
itemgetterobject
*
ig
;
PyObject
*
item
;
PyObject
*
item
;
in
t
nitems
;
Py_ssize_
t
nitems
;
if
(
!
_PyArg_NoKeywords
(
"itemgetter()"
,
kwds
))
if
(
!
_PyArg_NoKeywords
(
"itemgetter()"
,
kwds
))
return
NULL
;
return
NULL
;
...
@@ -352,7 +352,7 @@ static PyObject *
...
@@ -352,7 +352,7 @@ static PyObject *
itemgetter_call
(
itemgetterobject
*
ig
,
PyObject
*
args
,
PyObject
*
kw
)
itemgetter_call
(
itemgetterobject
*
ig
,
PyObject
*
args
,
PyObject
*
kw
)
{
{
PyObject
*
obj
,
*
result
;
PyObject
*
obj
,
*
result
;
in
t
i
,
nitems
=
ig
->
nitems
;
Py_ssize_
t
i
,
nitems
=
ig
->
nitems
;
if
(
!
PyArg_UnpackTuple
(
args
,
"itemgetter"
,
1
,
1
,
&
obj
))
if
(
!
PyArg_UnpackTuple
(
args
,
"itemgetter"
,
1
,
1
,
&
obj
))
return
NULL
;
return
NULL
;
...
@@ -435,7 +435,7 @@ static PyTypeObject itemgetter_type = {
...
@@ -435,7 +435,7 @@ static PyTypeObject itemgetter_type = {
typedef
struct
{
typedef
struct
{
PyObject_HEAD
PyObject_HEAD
in
t
nattrs
;
Py_ssize_
t
nattrs
;
PyObject
*
attr
;
PyObject
*
attr
;
}
attrgetterobject
;
}
attrgetterobject
;
...
@@ -446,7 +446,7 @@ attrgetter_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
...
@@ -446,7 +446,7 @@ attrgetter_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
{
attrgetterobject
*
ag
;
attrgetterobject
*
ag
;
PyObject
*
attr
;
PyObject
*
attr
;
in
t
nattrs
;
Py_ssize_
t
nattrs
;
if
(
!
_PyArg_NoKeywords
(
"attrgetter()"
,
kwds
))
if
(
!
_PyArg_NoKeywords
(
"attrgetter()"
,
kwds
))
return
NULL
;
return
NULL
;
...
@@ -491,7 +491,7 @@ static PyObject *
...
@@ -491,7 +491,7 @@ static PyObject *
attrgetter_call
(
attrgetterobject
*
ag
,
PyObject
*
args
,
PyObject
*
kw
)
attrgetter_call
(
attrgetterobject
*
ag
,
PyObject
*
args
,
PyObject
*
kw
)
{
{
PyObject
*
obj
,
*
result
;
PyObject
*
obj
,
*
result
;
in
t
i
,
nattrs
=
ag
->
nattrs
;
Py_ssize_
t
i
,
nattrs
=
ag
->
nattrs
;
if
(
!
PyArg_UnpackTuple
(
args
,
"attrgetter"
,
1
,
1
,
&
obj
))
if
(
!
PyArg_UnpackTuple
(
args
,
"attrgetter"
,
1
,
1
,
&
obj
))
return
NULL
;
return
NULL
;
...
...
Modules/parsermodule.c
View file @
452728f8
...
@@ -782,7 +782,7 @@ build_node_tree(PyObject *tuple)
...
@@ -782,7 +782,7 @@ build_node_tree(PyObject *tuple)
res
=
NULL
;
res
=
NULL
;
}
}
if
(
res
&&
encoding
)
{
if
(
res
&&
encoding
)
{
in
t
len
;
Py_ssize_
t
len
;
len
=
PyString_GET_SIZE
(
encoding
)
+
1
;
len
=
PyString_GET_SIZE
(
encoding
)
+
1
;
res
->
n_str
=
(
char
*
)
PyMem_MALLOC
(
len
);
res
->
n_str
=
(
char
*
)
PyMem_MALLOC
(
len
);
if
(
res
->
n_str
!=
NULL
)
if
(
res
->
n_str
!=
NULL
)
...
...
Modules/stropmodule.c
View file @
452728f8
...
@@ -166,8 +166,8 @@ strop_joinfields(PyObject *self, PyObject *args)
...
@@ -166,8 +166,8 @@ strop_joinfields(PyObject *self, PyObject *args)
{
{
PyObject
*
seq
;
PyObject
*
seq
;
char
*
sep
=
NULL
;
char
*
sep
=
NULL
;
in
t
seqlen
,
seplen
=
0
;
Py_ssize_
t
seqlen
,
seplen
=
0
;
in
t
i
,
reslen
=
0
,
slen
=
0
,
sz
=
100
;
Py_ssize_
t
i
,
reslen
=
0
,
slen
=
0
,
sz
=
100
;
PyObject
*
res
=
NULL
;
PyObject
*
res
=
NULL
;
char
*
p
=
NULL
;
char
*
p
=
NULL
;
ssizeargfunc
getitemfunc
;
ssizeargfunc
getitemfunc
;
...
@@ -921,10 +921,11 @@ static PyObject *
...
@@ -921,10 +921,11 @@ static PyObject *
strop_translate
(
PyObject
*
self
,
PyObject
*
args
)
strop_translate
(
PyObject
*
self
,
PyObject
*
args
)
{
{
register
char
*
input
,
*
table
,
*
output
;
register
char
*
input
,
*
table
,
*
output
;
register
int
i
,
c
,
changed
=
0
;
Py_ssize_t
i
;
int
c
,
changed
=
0
;
PyObject
*
input_obj
;
PyObject
*
input_obj
;
char
*
table1
,
*
output_start
,
*
del_table
=
NULL
;
char
*
table1
,
*
output_start
,
*
del_table
=
NULL
;
in
t
inlen
,
tablen
,
dellen
=
0
;
Py_ssize_
t
inlen
,
tablen
,
dellen
=
0
;
PyObject
*
result
;
PyObject
*
result
;
int
trans_table
[
256
];
int
trans_table
[
256
];
...
...
Modules/structmodule.c
View file @
452728f8
...
@@ -1031,7 +1031,7 @@ struct_pack(PyObject *self, PyObject *args)
...
@@ -1031,7 +1031,7 @@ struct_pack(PyObject *self, PyObject *args)
PyObject
*
format
,
*
result
,
*
v
;
PyObject
*
format
,
*
result
,
*
v
;
char
*
fmt
;
char
*
fmt
;
int
size
,
num
;
int
size
,
num
;
in
t
i
,
n
;
Py_ssize_
t
i
,
n
;
char
*
s
,
*
res
,
*
restart
,
*
nres
;
char
*
s
,
*
res
,
*
restart
,
*
nres
;
char
c
;
char
c
;
...
@@ -1097,7 +1097,7 @@ struct_pack(PyObject *self, PyObject *args)
...
@@ -1097,7 +1097,7 @@ struct_pack(PyObject *self, PyObject *args)
goto
fail
;
goto
fail
;
if
(
c
==
's'
)
{
if
(
c
==
's'
)
{
/* num is string size, not repeat count */
/* num is string size, not repeat count */
in
t
n
;
Py_ssize_
t
n
;
if
(
!
PyString_Check
(
v
))
{
if
(
!
PyString_Check
(
v
))
{
PyErr_SetString
(
StructError
,
PyErr_SetString
(
StructError
,
"argument for 's' must be a string"
);
"argument for 's' must be a string"
);
...
@@ -1116,7 +1116,7 @@ struct_pack(PyObject *self, PyObject *args)
...
@@ -1116,7 +1116,7 @@ struct_pack(PyObject *self, PyObject *args)
else
if
(
c
==
'p'
)
{
else
if
(
c
==
'p'
)
{
/* num is string size + 1,
/* num is string size + 1,
to fit in the count byte */
to fit in the count byte */
in
t
n
;
Py_ssize_
t
n
;
num
--
;
/* now num is max string size */
num
--
;
/* now num is max string size */
if
(
!
PyString_Check
(
v
))
{
if
(
!
PyString_Check
(
v
))
{
PyErr_SetString
(
StructError
,
PyErr_SetString
(
StructError
,
...
@@ -1133,7 +1133,8 @@ struct_pack(PyObject *self, PyObject *args)
...
@@ -1133,7 +1133,8 @@ struct_pack(PyObject *self, PyObject *args)
memset
(
res
+
1
+
n
,
'\0'
,
num
-
n
);
memset
(
res
+
1
+
n
,
'\0'
,
num
-
n
);
if
(
n
>
255
)
if
(
n
>
255
)
n
=
255
;
n
=
255
;
*
res
++
=
n
;
/* store the length byte */
/* store the length byte */
*
res
++
=
Py_SAFE_DOWNCAST
(
n
,
Py_ssize_t
,
char
);
res
+=
num
;
res
+=
num
;
break
;
break
;
}
}
...
...
Modules/zipimport.c
View file @
452728f8
...
@@ -408,7 +408,7 @@ zipimporter_get_data(PyObject *obj, PyObject *args)
...
@@ -408,7 +408,7 @@ zipimporter_get_data(PyObject *obj, PyObject *args)
char
*
p
,
buf
[
MAXPATHLEN
+
1
];
char
*
p
,
buf
[
MAXPATHLEN
+
1
];
#endif
#endif
PyObject
*
toc_entry
;
PyObject
*
toc_entry
;
in
t
len
;
Py_ssize_
t
len
;
if
(
!
PyArg_ParseTuple
(
args
,
"s:zipimporter.get_data"
,
&
path
))
if
(
!
PyArg_ParseTuple
(
args
,
"s:zipimporter.get_data"
,
&
path
))
return
NULL
;
return
NULL
;
...
@@ -910,7 +910,7 @@ unmarshal_code(char *pathname, PyObject *data, time_t mtime)
...
@@ -910,7 +910,7 @@ unmarshal_code(char *pathname, PyObject *data, time_t mtime)
{
{
PyObject
*
code
;
PyObject
*
code
;
char
*
buf
=
PyString_AsString
(
data
);
char
*
buf
=
PyString_AsString
(
data
);
in
t
size
=
PyString_Size
(
data
);
Py_ssize_
t
size
=
PyString_Size
(
data
);
if
(
size
<=
9
)
{
if
(
size
<=
9
)
{
PyErr_SetString
(
ZipImportError
,
PyErr_SetString
(
ZipImportError
,
...
...
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