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
98b40ad5
Commit
98b40ad5
authored
Jun 08, 2006
by
Georg Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug #1502805: don't alias file.__exit__ to file.close since the
latter can return something that's true.
parent
676725db
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
1 deletion
+18
-1
Objects/fileobject.c
Objects/fileobject.c
+18
-1
No files found.
Objects/fileobject.c
View file @
98b40ad5
...
...
@@ -1635,6 +1635,20 @@ file_self(PyFileObject *f)
return
(
PyObject
*
)
f
;
}
static
PyObject
*
file_exit
(
PyFileObject
*
f
,
PyObject
*
args
)
{
PyObject
*
ret
=
file_close
(
f
);
if
(
!
ret
)
/* If error occurred, pass through */
return
NULL
;
Py_DECREF
(
ret
);
/* We cannot return the result of close since a true
* value will be interpreted as "yes, swallow the
* exception if one was raised inside the with block". */
Py_RETURN_NONE
;
}
PyDoc_STRVAR
(
readline_doc
,
"readline([size]) -> next line from the file, as a string.
\n
"
"
\n
"
...
...
@@ -1722,6 +1736,9 @@ PyDoc_STRVAR(isatty_doc,
PyDoc_STRVAR
(
enter_doc
,
"__enter__() -> self."
);
PyDoc_STRVAR
(
exit_doc
,
"__exit__(*excinfo) -> None. Closes the file."
);
static
PyMethodDef
file_methods
[]
=
{
{
"readline"
,
(
PyCFunction
)
file_readline
,
METH_VARARGS
,
readline_doc
},
{
"read"
,
(
PyCFunction
)
file_read
,
METH_VARARGS
,
read_doc
},
...
...
@@ -1740,7 +1757,7 @@ static PyMethodDef file_methods[] = {
{
"close"
,
(
PyCFunction
)
file_close
,
METH_NOARGS
,
close_doc
},
{
"isatty"
,
(
PyCFunction
)
file_isatty
,
METH_NOARGS
,
isatty_doc
},
{
"__enter__"
,
(
PyCFunction
)
file_self
,
METH_NOARGS
,
enter_doc
},
{
"__exit__"
,
(
PyCFunction
)
file_
close
,
METH_VARARGS
,
close
_doc
},
{
"__exit__"
,
(
PyCFunction
)
file_
exit
,
METH_VARARGS
,
exit
_doc
},
{
NULL
,
NULL
}
/* sentinel */
};
...
...
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