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
ff83c2ba
Commit
ff83c2ba
authored
Feb 02, 2004
by
Hye-Shik Chang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix input() builtin function to respect compiler flags.
(SF patch 876178, patch by mwh, unittest by perky)
parent
96c44658
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
1 deletion
+20
-1
Lib/test/test_builtin.py
Lib/test/test_builtin.py
+13
-0
Misc/NEWS
Misc/NEWS
+3
-0
Python/bltinmodule.c
Python/bltinmodule.c
+4
-1
No files found.
Lib/test/test_builtin.py
View file @
ff83c2ba
...
@@ -931,6 +931,19 @@ class BuiltinTest(unittest.TestCase):
...
@@ -931,6 +931,19 @@ class BuiltinTest(unittest.TestCase):
self
.
assertEqual
(
input
(),
'whitespace'
)
self
.
assertEqual
(
input
(),
'whitespace'
)
sys
.
stdin
=
cStringIO
.
StringIO
()
sys
.
stdin
=
cStringIO
.
StringIO
()
self
.
assertRaises
(
EOFError
,
input
)
self
.
assertRaises
(
EOFError
,
input
)
# SF 876178: make sure input() respect future options.
sys
.
stdin
=
cStringIO
.
StringIO
(
'1/2'
)
sys
.
stdout
=
cStringIO
.
StringIO
()
exec
compile
(
'print input()'
,
'test_builtin_tmp'
,
'exec'
)
sys
.
stdin
.
seek
(
0
,
0
)
exec
compile
(
'from __future__ import division;print input()'
,
'test_builtin_tmp'
,
'exec'
)
sys
.
stdin
.
seek
(
0
,
0
)
exec
compile
(
'print input()'
,
'test_builtin_tmp'
,
'exec'
)
self
.
assertEqual
(
sys
.
stdout
.
getvalue
().
splitlines
(),
[
'0'
,
'0.5'
,
'0'
])
del
sys
.
stdout
del
sys
.
stdout
self
.
assertRaises
(
RuntimeError
,
input
,
'prompt'
)
self
.
assertRaises
(
RuntimeError
,
input
,
'prompt'
)
del
sys
.
stdin
del
sys
.
stdin
...
...
Misc/NEWS
View file @
ff83c2ba
...
@@ -12,6 +12,9 @@ What's New in Python 2.4 alpha 1?
...
@@ -12,6 +12,9 @@ What's New in Python 2.4 alpha 1?
Core and builtins
Core and builtins
-----------------
-----------------
- input() builtin function now respects compiler flags such as
__future__ statements. SF patch 876178.
- Removed PendingDeprecationWarning from apply(). apply() remains
- Removed PendingDeprecationWarning from apply(). apply() remains
deprecated, but the nuisance warning will not be issued.
deprecated, but the nuisance warning will not be issued.
...
...
Python/bltinmodule.c
View file @
ff83c2ba
...
@@ -979,6 +979,7 @@ builtin_input(PyObject *self, PyObject *args)
...
@@ -979,6 +979,7 @@ builtin_input(PyObject *self, PyObject *args)
char
*
str
;
char
*
str
;
PyObject
*
res
;
PyObject
*
res
;
PyObject
*
globals
,
*
locals
;
PyObject
*
globals
,
*
locals
;
PyCompilerFlags
cf
;
line
=
builtin_raw_input
(
self
,
args
);
line
=
builtin_raw_input
(
self
,
args
);
if
(
line
==
NULL
)
if
(
line
==
NULL
)
...
@@ -994,7 +995,9 @@ builtin_input(PyObject *self, PyObject *args)
...
@@ -994,7 +995,9 @@ builtin_input(PyObject *self, PyObject *args)
PyEval_GetBuiltins
())
!=
0
)
PyEval_GetBuiltins
())
!=
0
)
return
NULL
;
return
NULL
;
}
}
res
=
PyRun_String
(
str
,
Py_eval_input
,
globals
,
locals
);
cf
.
cf_flags
=
0
;
PyEval_MergeCompilerFlags
(
&
cf
);
res
=
PyRun_StringFlags
(
str
,
Py_eval_input
,
globals
,
locals
,
&
cf
);
Py_DECREF
(
line
);
Py_DECREF
(
line
);
return
res
;
return
res
;
}
}
...
...
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