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
ad7736fa
Commit
ad7736fa
authored
Sep 25, 2019
by
Dong-hee Na
Committed by
Serhiy Storchaka
Sep 25, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-38265: Update os.pread to accept the length type as Py_ssize_t. (GH-16359)
parent
12f209ec
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
10 deletions
+19
-10
Misc/NEWS.d/next/Library/2019-09-25-05-16-19.bpo-38265.X6-gsT.rst
...S.d/next/Library/2019-09-25-05-16-19.bpo-38265.X6-gsT.rst
+2
-0
Modules/clinic/posixmodule.c.h
Modules/clinic/posixmodule.c.h
+14
-6
Modules/posixmodule.c
Modules/posixmodule.c
+3
-4
No files found.
Misc/NEWS.d/next/Library/2019-09-25-05-16-19.bpo-38265.X6-gsT.rst
0 → 100644
View file @
ad7736fa
Update the *length* parameter of :func:`os.pread` to accept
:c:type:`Py_ssize_t` instead of :c:type:`int`.
Modules/clinic/posixmodule.c.h
View file @
ad7736fa
...
...
@@ -4799,14 +4799,14 @@ PyDoc_STRVAR(os_pread__doc__,
{"pread", (PyCFunction)(void(*)(void))os_pread, METH_FASTCALL, os_pread__doc__},
static
PyObject
*
os_pread_impl
(
PyObject
*
module
,
int
fd
,
in
t
length
,
Py_off_t
offset
);
os_pread_impl
(
PyObject
*
module
,
int
fd
,
Py_ssize_
t
length
,
Py_off_t
offset
);
static
PyObject
*
os_pread
(
PyObject
*
module
,
PyObject
*
const
*
args
,
Py_ssize_t
nargs
)
{
PyObject
*
return_value
=
NULL
;
int
fd
;
in
t
length
;
Py_ssize_
t
length
;
Py_off_t
offset
;
if
(
!
_PyArg_CheckPositional
(
"pread"
,
nargs
,
3
,
3
))
{
...
...
@@ -4826,9 +4826,17 @@ os_pread(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
"integer argument expected, got float"
);
goto
exit
;
}
length
=
_PyLong_AsInt
(
args
[
1
]);
if
(
length
==
-
1
&&
PyErr_Occurred
())
{
goto
exit
;
{
Py_ssize_t
ival
=
-
1
;
PyObject
*
iobj
=
PyNumber_Index
(
args
[
1
]);
if
(
iobj
!=
NULL
)
{
ival
=
PyLong_AsSsize_t
(
iobj
);
Py_DECREF
(
iobj
);
}
if
(
ival
==
-
1
&&
PyErr_Occurred
())
{
goto
exit
;
}
length
=
ival
;
}
if
(
!
Py_off_t_converter
(
args
[
2
],
&
offset
))
{
goto
exit
;
...
...
@@ -8723,4 +8731,4 @@ exit:
#ifndef OS__REMOVE_DLL_DIRECTORY_METHODDEF
#define OS__REMOVE_DLL_DIRECTORY_METHODDEF
#endif
/* !defined(OS__REMOVE_DLL_DIRECTORY_METHODDEF) */
/*[clinic end generated code: output=
113d9fbdd18a62f
5 input=a9049054013a1b77]*/
/*[clinic end generated code: output=
799c75140d84ace
5 input=a9049054013a1b77]*/
Modules/posixmodule.c
View file @
ad7736fa
...
...
@@ -8827,11 +8827,10 @@ os_readv_impl(PyObject *module, int fd, PyObject *buffers)
#ifdef HAVE_PREAD
/*[clinic input]
# TODO length should be size_t! but Python doesn't support parsing size_t yet.
os.pread
fd: int
length:
in
t
length:
Py_ssize_
t
offset: Py_off_t
/
...
...
@@ -8842,8 +8841,8 @@ the beginning of the file. The file offset remains unchanged.
[clinic start generated code]*/
static
PyObject
*
os_pread_impl
(
PyObject
*
module
,
int
fd
,
in
t
length
,
Py_off_t
offset
)
/*[clinic end generated code: output=
435b29ee32b54a78 input=084948dcbaa35d4c
]*/
os_pread_impl
(
PyObject
*
module
,
int
fd
,
Py_ssize_
t
length
,
Py_off_t
offset
)
/*[clinic end generated code: output=
3f875c1eef82e32f input=85cb4a5589627144
]*/
{
Py_ssize_t
n
;
int
async_err
=
0
;
...
...
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