Skip to content

Commit 1ddd773

Browse files
gh-64020: Deprecate pydoc.ispackage() (GH-20908)
Co-authored-by: Serhiy Storchaka <[email protected]>
1 parent 4acf825 commit 1ddd773

File tree

4 files changed

+12
-2
lines changed

4 files changed

+12
-2
lines changed

Doc/whatsnew/3.13.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,9 @@ Deprecated
556556
coroutine.
557557
(Contributed by Irit Katriel in :gh:`81137`.)
558558

559+
* Deprecate undocumented :func:`!pydoc.ispackage` function.
560+
(Contributed by Zackery Spytz in :gh:`64020`.)
561+
559562

560563
Pending Removal in Python 3.14
561564
------------------------------

Lib/pydoc.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,8 @@ def sort_attributes(attrs, object):
345345

346346
def ispackage(path):
347347
"""Guess whether a path refers to a package directory."""
348+
warnings.warn('The pydoc.ispackage() function is deprecated',
349+
DeprecationWarning, stacklevel=2)
348350
if os.path.isdir(path):
349351
for ext in ('.py', '.pyc'):
350352
if os.path.isfile(os.path.join(path, '__init__' + ext)):

Lib/test/test_pydoc.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -745,14 +745,18 @@ def test_splitdoc_with_description(self):
745745

746746
def test_is_package_when_not_package(self):
747747
with os_helper.temp_cwd() as test_dir:
748-
self.assertFalse(pydoc.ispackage(test_dir))
748+
with self.assertWarns(DeprecationWarning) as cm:
749+
self.assertFalse(pydoc.ispackage(test_dir))
750+
self.assertEqual(cm.filename, __file__)
749751

750752
def test_is_package_when_is_package(self):
751753
with os_helper.temp_cwd() as test_dir:
752754
init_path = os.path.join(test_dir, '__init__.py')
753755
open(init_path, 'w').close()
754-
self.assertTrue(pydoc.ispackage(test_dir))
756+
with self.assertWarns(DeprecationWarning) as cm:
757+
self.assertTrue(pydoc.ispackage(test_dir))
755758
os.remove(init_path)
759+
self.assertEqual(cm.filename, __file__)
756760

757761
def test_allmethods(self):
758762
# issue 17476: allmethods was no longer returning unbound methods.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The :func:`!pydoc.ispackage` function has been deprecated.

0 commit comments

Comments
 (0)