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
7e3ba2a6
Commit
7e3ba2a6
authored
Aug 06, 2006
by
Georg Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug #1535165: fixed a segfault in input() and raw_input() when
sys.stdin is closed.
parent
534fe18e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
1 deletion
+12
-1
Lib/test/test_builtin.py
Lib/test/test_builtin.py
+8
-0
Misc/NEWS
Misc/NEWS
+3
-0
Python/bltinmodule.c
Python/bltinmodule.c
+1
-1
No files found.
Lib/test/test_builtin.py
View file @
7e3ba2a6
...
...
@@ -1432,6 +1432,14 @@ class BuiltinTest(unittest.TestCase):
self
.
assertEqual
(
input
(
'testing
\
n
'
),
2
)
self
.
assertEqual
(
raw_input
(),
'The quick brown fox jumps over the lazy dog.'
)
self
.
assertEqual
(
raw_input
(
'testing
\
n
'
),
'Dear John'
)
# SF 1535165: don't segfault on closed stdin
# sys.stdout must be a regular file for triggering
sys
.
stdout
=
savestdout
sys
.
stdin
.
close
()
self
.
assertRaises
(
ValueError
,
input
,
'prompt'
)
sys
.
stdout
=
BitBucket
()
sys
.
stdin
=
cStringIO
.
StringIO
(
"NULL
\
0
"
)
self
.
assertRaises
(
TypeError
,
input
,
42
,
42
)
sys
.
stdin
=
cStringIO
.
StringIO
(
" 'whitespace'"
)
...
...
Misc/NEWS
View file @
7e3ba2a6
...
...
@@ -12,6 +12,9 @@ What's New in Python 2.5 release candidate 1?
Core and builtins
-----------------
- Bug #1535165: fixed a segfault in input() and raw_input() when
sys.stdin is closed.
- On Windows, the PyErr_Warn function is now exported from
the Python dll again.
...
...
Python/bltinmodule.c
View file @
7e3ba2a6
...
...
@@ -1725,7 +1725,7 @@ builtin_raw_input(PyObject *self, PyObject *args)
if
(
PyFile_WriteString
(
" "
,
fout
)
!=
0
)
return
NULL
;
}
if
(
PyFile_
Check
(
fin
)
&&
PyFile_Check
(
fout
)
if
(
PyFile_
AsFile
(
fin
)
&&
PyFile_AsFile
(
fout
)
&&
isatty
(
fileno
(
PyFile_AsFile
(
fin
)))
&&
isatty
(
fileno
(
PyFile_AsFile
(
fout
))))
{
PyObject
*
po
;
...
...
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