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
f5f4edcb
Commit
f5f4edcb
authored
Jul 13, 2000
by
Andrew M. Kuchling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use PyObject_AsFileDescriptor
parent
05b871c8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
68 deletions
+4
-68
Modules/_tkinter.c
Modules/_tkinter.c
+2
-44
Modules/selectmodule.c
Modules/selectmodule.c
+2
-24
No files found.
Modules/_tkinter.c
View file @
f5f4edcb
...
...
@@ -1426,48 +1426,6 @@ FileHandler(ClientData clientData, int mask)
LEAVE_PYTHON
}
static
int
GetFileNo
(
PyObject
*
file
)
/* Either an int >= 0 or an object with a
*.fileno() method that returns an int >= 0
*/
{
PyObject
*
meth
,
*
args
,
*
res
;
int
id
;
if
(
PyInt_Check
(
file
))
{
id
=
PyInt_AsLong
(
file
);
if
(
id
<
0
)
PyErr_SetString
(
PyExc_ValueError
,
"invalid file id"
);
return
id
;
}
args
=
PyTuple_New
(
0
);
if
(
args
==
NULL
)
return
-
1
;
meth
=
PyObject_GetAttrString
(
file
,
"fileno"
);
if
(
meth
==
NULL
)
{
Py_DECREF
(
args
);
return
-
1
;
}
res
=
PyEval_CallObject
(
meth
,
args
);
Py_DECREF
(
args
);
Py_DECREF
(
meth
);
if
(
res
==
NULL
)
return
-
1
;
if
(
PyInt_Check
(
res
))
id
=
PyInt_AsLong
(
res
);
else
id
=
-
1
;
if
(
id
<
0
)
PyErr_SetString
(
PyExc_ValueError
,
"invalid fileno() return value"
);
Py_DECREF
(
res
);
return
id
;
}
static
PyObject
*
Tkapp_CreateFileHandler
(
PyObject
*
self
,
PyObject
*
args
)
/* args is (file, mask, func) */
...
...
@@ -1478,7 +1436,7 @@ Tkapp_CreateFileHandler(PyObject *self, PyObject *args)
if
(
!
PyArg_ParseTuple
(
args
,
"OiO:createfilehandler"
,
&
file
,
&
mask
,
&
func
))
return
NULL
;
tfile
=
GetFileNo
(
file
);
tfile
=
PyObject_AsFileDescriptor
(
file
);
if
(
tfile
<
0
)
return
NULL
;
if
(
!
PyCallable_Check
(
func
))
{
...
...
@@ -1506,7 +1464,7 @@ Tkapp_DeleteFileHandler(PyObject *self, PyObject *args)
if
(
!
PyArg_ParseTuple
(
args
,
"O:deletefilehandler"
,
&
file
))
return
NULL
;
tfile
=
GetFileNo
(
file
);
tfile
=
PyObject_AsFileDescriptor
(
file
);
if
(
tfile
<
0
)
return
NULL
;
...
...
Modules/selectmodule.c
View file @
f5f4edcb
...
...
@@ -96,31 +96,9 @@ list2set(PyObject *list, fd_set *set, pylist fd2obj[FD_SETSIZE + 3])
return
-
1
;
Py_INCREF
(
o
);
v
=
PyObject_AsFileDescriptor
(
o
);
if
(
v
==
-
1
)
goto
finally
;
if
(
PyInt_Check
(
o
))
{
v
=
PyInt_AsLong
(
o
);
}
else
if
((
meth
=
PyObject_GetAttrString
(
o
,
"fileno"
))
!=
NULL
)
{
PyObject
*
fno
=
PyEval_CallObject
(
meth
,
NULL
);
Py_DECREF
(
meth
);
if
(
fno
==
NULL
)
goto
finally
;
if
(
!
PyInt_Check
(
fno
))
{
PyErr_SetString
(
PyExc_TypeError
,
"fileno method returned a non-integer"
);
Py_DECREF
(
fno
);
goto
finally
;
}
v
=
PyInt_AsLong
(
fno
);
Py_DECREF
(
fno
);
}
else
{
PyErr_SetString
(
PyExc_TypeError
,
"argument must be an int, or have a fileno() method."
);
goto
finally
;
}
#if defined(_MSC_VER)
max
=
0
;
/* not used for Win32 */
#else
/* !_MSC_VER */
...
...
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