Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
7065f376
Kaydet (Commit)
7065f376
authored
Şub 20, 2015
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Issue #23374: Fixed pydoc failure with non-ASCII files when stdout encoding
differs from file system encoding (e.g. on Mac OS).
üst
78a82491
5e3d7a40
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
9 deletions
+25
-9
pydoc.py
Lib/pydoc.py
+13
-9
test_pydoc.py
Lib/test/test_pydoc.py
+9
-0
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/pydoc.py
Dosyayı görüntüle @
7065f376
...
...
@@ -1405,9 +1405,6 @@ class _PlainTextDoc(TextDoc):
def
pager
(
text
):
"""The first time this is called, determine what kind of pager to use."""
global
pager
# Escape non-encodable characters to avoid encoding errors later
encoding
=
sys
.
getfilesystemencoding
()
text
=
text
.
encode
(
encoding
,
'backslashreplace'
)
.
decode
(
encoding
)
pager
=
getpager
()
pager
(
text
)
...
...
@@ -1450,10 +1447,12 @@ def plain(text):
def
pipepager
(
text
,
cmd
):
"""Page through text by feeding it to another program."""
pipe
=
os
.
popen
(
cmd
,
'w'
)
import
subprocess
proc
=
subprocess
.
Popen
(
cmd
,
shell
=
True
,
stdin
=
subprocess
.
PIPE
)
try
:
pipe
.
write
(
text
)
pipe
.
close
()
with
proc
:
with
io
.
TextIOWrapper
(
proc
.
stdin
,
errors
=
'backslashreplace'
)
as
pipe
:
pipe
.
write
(
text
)
except
OSError
:
pass
# Ignore broken pipes caused by quitting the pager program.
...
...
@@ -1461,16 +1460,21 @@ def tempfilepager(text, cmd):
"""Page through text by invoking a program on a temporary file."""
import
tempfile
filename
=
tempfile
.
mktemp
()
with
open
(
filename
,
'w'
)
as
file
:
with
open
(
filename
,
'w'
,
errors
=
'backslashreplace'
)
as
file
:
file
.
write
(
text
)
try
:
os
.
system
(
cmd
+
' "'
+
filename
+
'"'
)
finally
:
os
.
unlink
(
filename
)
def
_escape_stdout
(
text
):
# Escape non-encodable characters to avoid encoding errors later
encoding
=
getattr
(
sys
.
stdout
,
'encoding'
,
None
)
or
'utf-8'
return
text
.
encode
(
encoding
,
'backslashreplace'
)
.
decode
(
encoding
)
def
ttypager
(
text
):
"""Page through text on a text terminal."""
lines
=
plain
(
text
)
.
split
(
'
\n
'
)
lines
=
plain
(
_escape_stdout
(
text
)
)
.
split
(
'
\n
'
)
try
:
import
tty
fd
=
sys
.
stdin
.
fileno
()
...
...
@@ -1514,7 +1518,7 @@ def ttypager(text):
def
plainpager
(
text
):
"""Simply print unformatted text. This is the ultimate fallback."""
sys
.
stdout
.
write
(
plain
(
text
))
sys
.
stdout
.
write
(
plain
(
_escape_stdout
(
text
)
))
def
describe
(
thing
):
"""Produce a short description of the given thing."""
...
...
Lib/test/test_pydoc.py
Dosyayı görüntüle @
7065f376
...
...
@@ -34,6 +34,10 @@ try:
except
ImportError
:
threading
=
None
class
nonascii
:
'Це не латиниця'
pass
if
test
.
support
.
HAVE_DOCSTRINGS
:
expected_data_docstrings
=
(
'dictionary for instance variables (if defined)'
,
...
...
@@ -460,6 +464,11 @@ class PydocDocTest(unittest.TestCase):
self
.
assertEqual
(
expected
,
result
,
"documentation for missing module found"
)
def
test_not_ascii
(
self
):
result
=
run_pydoc
(
'test.test_pydoc.nonascii'
,
PYTHONIOENCODING
=
'ascii'
)
encoded
=
nonascii
.
__doc__
.
encode
(
'ascii'
,
'backslashreplace'
)
self
.
assertIn
(
encoded
,
result
)
def
test_input_strip
(
self
):
missing_module
=
" test.i_am_not_here "
result
=
str
(
run_pydoc
(
missing_module
),
'ascii'
)
...
...
Misc/NEWS
Dosyayı görüntüle @
7065f376
...
...
@@ -13,6 +13,9 @@ Core and Builtins
Library
-------
- Issue #23374: Fixed pydoc failure with non-ASCII files when stdout encoding
differs from file system encoding (e.g. on Mac OS).
- Issue #23481: Remove RC4 from the SSL module'
s
default
cipher
list
.
-
Issue
#
21548
:
Fix
pydoc
.
synopsis
()
and
pydoc
.
apropos
()
on
modules
with
empty
...
...
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