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
6b14491b
Commit
6b14491b
authored
Mar 14, 1995
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mode and optional bufsize for makefile()
parent
b045afc7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
6 deletions
+15
-6
Modules/socketmodule.c
Modules/socketmodule.c
+15
-6
No files found.
Modules/socketmodule.c
View file @
6b14491b
...
...
@@ -59,7 +59,7 @@ Socket methods:
- s.getsockname() --> sockaddr
- s.getpeername() --> sockaddr
- s.listen(n) --> Py_None
- s.makefile(
mode
) --> file object
- s.makefile(
[mode[, bufsize]]
) --> file object
- s.recv(nbytes [,flags]) --> string
- s.recvfrom(nbytes [,flags]) --> string, sockaddr
- s.send(string [,flags]) --> nbytes
...
...
@@ -733,15 +733,24 @@ static PyObject *
BUILD_FUNC_DEF_2
(
PySocketSock_makefile
,
PySocketSockObject
*
,
s
,
PyObject
*
,
args
)
{
extern
int
fclose
Py_PROTO
((
FILE
*
));
char
*
mode
;
char
*
mode
=
"r"
;
int
bufsize
=
-
1
;
int
fd
;
FILE
*
fp
;
if
(
!
PyArg_Parse
(
args
,
"s"
,
&
mode
))
PyObject
*
f
;
if
(
!
PyArg_ParseTuple
(
args
,
"|si"
,
&
mode
,
&
bufsize
))
return
NULL
;
if
((
fd
=
dup
(
s
->
sock_fd
))
<
0
||
(
fp
=
fdopen
(
fd
,
mode
))
==
NULL
)
(
fp
=
fdopen
(
fd
,
mode
))
==
NULL
)
{
if
(
fd
>=
0
)
close
(
fd
);
return
PySocket_Err
();
return
PyFile_FromFile
(
fp
,
"<socket>"
,
mode
,
fclose
);
}
f
=
PyFile_FromFile
(
fp
,
"<socket>"
,
mode
,
fclose
);
if
(
f
!=
NULL
)
PyFile_SetBufSize
(
f
,
bufsize
);
return
f
;
}
#endif
/* NO_DUP */
...
...
@@ -900,7 +909,7 @@ static PyMethodDef PySocketSock_methods[] = {
#endif
{
"listen"
,
(
PyCFunction
)
PySocketSock_listen
},
#ifndef NO_DUP
{
"makefile"
,
(
PyCFunction
)
PySocketSock_makefile
},
{
"makefile"
,
(
PyCFunction
)
PySocketSock_makefile
,
1
},
#endif
{
"recv"
,
(
PyCFunction
)
PySocketSock_recv
},
{
"recvfrom"
,
(
PyCFunction
)
PySocketSock_recvfrom
},
...
...
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