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
9ad0aae6
Kaydet (Commit)
9ad0aae6
authored
Kas 06, 2015
tarafından
Martin Panter
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #18010: Fix pydoc web server search to handle package exceptions
Implementation by Antoine Pitrou.
üst
ade04126
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
7 deletions
+38
-7
pydoc.py
Lib/pydoc.py
+3
-1
test_pydoc.py
Lib/test/test_pydoc.py
+32
-6
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/pydoc.py
Dosyayı görüntüle @
9ad0aae6
...
@@ -2355,7 +2355,9 @@ def _url_handler(url, content_type="text/html"):
...
@@ -2355,7 +2355,9 @@ def _url_handler(url, content_type="text/html"):
with
warnings
.
catch_warnings
():
with
warnings
.
catch_warnings
():
warnings
.
filterwarnings
(
'ignore'
)
# ignore problems during import
warnings
.
filterwarnings
(
'ignore'
)
# ignore problems during import
ModuleScanner
()
.
run
(
callback
,
key
)
def
onerror
(
modname
):
pass
ModuleScanner
()
.
run
(
callback
,
key
,
onerror
=
onerror
)
# format page
# format page
def
bltinlink
(
name
):
def
bltinlink
(
name
):
...
...
Lib/test/test_pydoc.py
Dosyayı görüntüle @
9ad0aae6
...
@@ -403,6 +403,13 @@ class PydocBaseTest(unittest.TestCase):
...
@@ -403,6 +403,13 @@ class PydocBaseTest(unittest.TestCase):
finally
:
finally
:
pkgutil
.
walk_packages
=
walk_packages
pkgutil
.
walk_packages
=
walk_packages
def
call_url_handler
(
self
,
url
,
expected_title
):
text
=
pydoc
.
_url_handler
(
url
,
"text/html"
)
result
=
get_html_title
(
text
)
# Check the title to ensure an unexpected error page was not returned
self
.
assertEqual
(
result
,
expected_title
,
text
)
return
text
class
PydocDocTest
(
unittest
.
TestCase
):
class
PydocDocTest
(
unittest
.
TestCase
):
...
@@ -715,6 +722,29 @@ class PydocImportTest(PydocBaseTest):
...
@@ -715,6 +722,29 @@ class PydocImportTest(PydocBaseTest):
finally
:
finally
:
os
.
chmod
(
pkgdir
,
current_mode
)
os
.
chmod
(
pkgdir
,
current_mode
)
def
test_url_search_package_error
(
self
):
# URL handler search should cope with packages that raise exceptions
pkgdir
=
os
.
path
.
join
(
TESTFN
,
"test_error_package"
)
os
.
mkdir
(
pkgdir
)
init
=
os
.
path
.
join
(
pkgdir
,
"__init__.py"
)
with
open
(
init
,
"wt"
,
encoding
=
"ascii"
)
as
f
:
f
.
write
(
"""raise ValueError("ouch")
\n
"""
)
with
self
.
restrict_walk_packages
(
path
=
[
TESTFN
]):
# Package has to be importable for the error to have any effect
saved_paths
=
tuple
(
sys
.
path
)
sys
.
path
.
insert
(
0
,
TESTFN
)
try
:
with
self
.
assertRaisesRegex
(
ValueError
,
"ouch"
):
import
test_error_package
# Sanity check
text
=
self
.
call_url_handler
(
"search?key=test_error_package"
,
"Pydoc: Search Results"
)
found
=
(
'<a href="test_error_package.html">'
'test_error_package</a>'
)
self
.
assertIn
(
found
,
text
)
finally
:
sys
.
path
[:]
=
saved_paths
@unittest.skip
(
'causes undesireable side-effects (#20128)'
)
@unittest.skip
(
'causes undesireable side-effects (#20128)'
)
def
test_modules
(
self
):
def
test_modules
(
self
):
# See Helper.listmodules().
# See Helper.listmodules().
...
@@ -891,16 +921,12 @@ class PydocUrlHandlerTest(PydocBaseTest):
...
@@ -891,16 +921,12 @@ class PydocUrlHandlerTest(PydocBaseTest):
with
self
.
restrict_walk_packages
():
with
self
.
restrict_walk_packages
():
for
url
,
title
in
requests
:
for
url
,
title
in
requests
:
text
=
pydoc
.
_url_handler
(
url
,
"text/html"
)
self
.
call_url_handler
(
url
,
title
)
result
=
get_html_title
(
text
)
self
.
assertEqual
(
result
,
title
,
text
)
path
=
string
.
__file__
path
=
string
.
__file__
title
=
"Pydoc: getfile "
+
path
title
=
"Pydoc: getfile "
+
path
url
=
"getfile?key="
+
path
url
=
"getfile?key="
+
path
text
=
pydoc
.
_url_handler
(
url
,
"text/html"
)
self
.
call_url_handler
(
url
,
title
)
result
=
get_html_title
(
text
)
self
.
assertEqual
(
result
,
title
)
class
TestHelper
(
unittest
.
TestCase
):
class
TestHelper
(
unittest
.
TestCase
):
...
...
Misc/NEWS
Dosyayı görüntüle @
9ad0aae6
...
@@ -96,6 +96,9 @@ Core and Builtins
...
@@ -96,6 +96,9 @@ Core and Builtins
Library
Library
-------
-------
- Issue #18010: Fix the pydoc web server's module search function to handle
exceptions from importing packages.
- Issue #25510: fileinput.FileInput.readline() now returns b'' instead of ''
- Issue #25510: fileinput.FileInput.readline() now returns b'' instead of ''
at the end if the FileInput was opened with binary mode.
at the end if the FileInput was opened with binary mode.
Patch by Ryosuke Ito.
Patch by Ryosuke Ito.
...
...
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