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
937ff1db
Commit
937ff1db
authored
Mar 25, 2012
by
Andrew Svetlov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #14200 — now displayhook for IDLE works in non-subprocess mode as well as subprecess.
parent
5b032f41
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
21 deletions
+22
-21
Lib/idlelib/PyShell.py
Lib/idlelib/PyShell.py
+2
-0
Lib/idlelib/rpc.py
Lib/idlelib/rpc.py
+19
-0
Lib/idlelib/run.py
Lib/idlelib/run.py
+1
-21
No files found.
Lib/idlelib/PyShell.py
View file @
937ff1db
...
@@ -999,6 +999,8 @@ class PyShell(OutputWindow):
...
@@ -999,6 +999,8 @@ class PyShell(OutputWindow):
return
False
return
False
else
:
else
:
nosub
=
"==== No Subprocess ===="
nosub
=
"==== No Subprocess ===="
sys
.
displayhook
=
rpc
.
displayhook
self
.
write
(
"Python %s on %s
\
n
%s
\
n
%s"
%
self
.
write
(
"Python %s on %s
\
n
%s
\
n
%s"
%
(
sys
.
version
,
sys
.
platform
,
self
.
COPYRIGHT
,
nosub
))
(
sys
.
version
,
sys
.
platform
,
self
.
COPYRIGHT
,
nosub
))
self
.
showprompt
()
self
.
showprompt
()
...
...
Lib/idlelib/rpc.py
View file @
937ff1db
...
@@ -40,6 +40,7 @@ import traceback
...
@@ -40,6 +40,7 @@ import traceback
import
copyreg
import
copyreg
import
types
import
types
import
marshal
import
marshal
import
builtins
def
unpickle_code
(
ms
):
def
unpickle_code
(
ms
):
...
@@ -603,3 +604,21 @@ class MethodProxy(object):
...
@@ -603,3 +604,21 @@ class MethodProxy(object):
# XXX KBK 09Sep03 We need a proper unit test for this module. Previously
# XXX KBK 09Sep03 We need a proper unit test for this module. Previously
# existing test code was removed at Rev 1.27 (r34098).
# existing test code was removed at Rev 1.27 (r34098).
def
displayhook
(
value
):
"""Override standard display hook to use non-locale encoding"""
if
value
is
None
:
return
# Set '_' to None to avoid recursion
builtins
.
_
=
None
text
=
repr
(
value
)
try
:
sys
.
stdout
.
write
(
text
)
except
UnicodeEncodeError
:
# let's use ascii while utf8-bmp codec doesn't present
encoding
=
'ascii'
bytes
=
text
.
encode
(
encoding
,
'backslashreplace'
)
text
=
bytes
.
decode
(
encoding
,
'strict'
)
sys
.
stdout
.
write
(
text
)
sys
.
stdout
.
write
(
"
\
n
"
)
builtins
.
_
=
value
Lib/idlelib/run.py
View file @
937ff1db
...
@@ -6,7 +6,6 @@ import traceback
...
@@ -6,7 +6,6 @@ import traceback
import
_thread
as
thread
import
_thread
as
thread
import
threading
import
threading
import
queue
import
queue
import
builtins
from
idlelib
import
CallTips
from
idlelib
import
CallTips
from
idlelib
import
AutoComplete
from
idlelib
import
AutoComplete
...
@@ -262,25 +261,6 @@ class MyRPCServer(rpc.RPCServer):
...
@@ -262,25 +261,6 @@ class MyRPCServer(rpc.RPCServer):
thread
.
interrupt_main
()
thread
.
interrupt_main
()
def
displayhook
(
value
):
"""Override standard display hook to use non-locale encoding"""
if
value
is
None
:
return
# Set '_' to None to avoid recursion
builtins
.
_
=
None
text
=
repr
(
value
)
try
:
sys
.
stdout
.
write
(
text
)
except
UnicodeEncodeError
:
# let's use ascii while utf8-bmp codec doesn't present
encoding
=
'ascii'
bytes
=
text
.
encode
(
encoding
,
'backslashreplace'
)
text
=
bytes
.
decode
(
encoding
,
'strict'
)
sys
.
stdout
.
write
(
text
)
sys
.
stdout
.
write
(
"
\
n
"
)
builtins
.
_
=
value
class
MyHandler
(
rpc
.
RPCHandler
):
class
MyHandler
(
rpc
.
RPCHandler
):
def
handle
(
self
):
def
handle
(
self
):
...
@@ -290,7 +270,7 @@ class MyHandler(rpc.RPCHandler):
...
@@ -290,7 +270,7 @@ class MyHandler(rpc.RPCHandler):
sys
.
stdin
=
self
.
console
=
self
.
get_remote_proxy
(
"stdin"
)
sys
.
stdin
=
self
.
console
=
self
.
get_remote_proxy
(
"stdin"
)
sys
.
stdout
=
self
.
get_remote_proxy
(
"stdout"
)
sys
.
stdout
=
self
.
get_remote_proxy
(
"stdout"
)
sys
.
stderr
=
self
.
get_remote_proxy
(
"stderr"
)
sys
.
stderr
=
self
.
get_remote_proxy
(
"stderr"
)
sys
.
displayhook
=
displayhook
sys
.
displayhook
=
rpc
.
displayhook
# page help() text to shell.
# page help() text to shell.
import
pydoc
# import must be done here to capture i/o binding
import
pydoc
# import must be done here to capture i/o binding
pydoc
.
pager
=
pydoc
.
plainpager
pydoc
.
pager
=
pydoc
.
plainpager
...
...
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