mirror of
https://github.com/python/cpython.git
synced 2025-10-17 20:28:43 +00:00
gh-64020: Deprecate pydoc.ispackage() (GH-20908)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
parent
4acf825058
commit
1ddd773293
4 changed files with 12 additions and 2 deletions
|
@ -556,6 +556,9 @@ Deprecated
|
||||||
coroutine.
|
coroutine.
|
||||||
(Contributed by Irit Katriel in :gh:`81137`.)
|
(Contributed by Irit Katriel in :gh:`81137`.)
|
||||||
|
|
||||||
|
* Deprecate undocumented :func:`!pydoc.ispackage` function.
|
||||||
|
(Contributed by Zackery Spytz in :gh:`64020`.)
|
||||||
|
|
||||||
|
|
||||||
Pending Removal in Python 3.14
|
Pending Removal in Python 3.14
|
||||||
------------------------------
|
------------------------------
|
||||||
|
|
|
@ -345,6 +345,8 @@ def sort_attributes(attrs, object):
|
||||||
|
|
||||||
def ispackage(path):
|
def ispackage(path):
|
||||||
"""Guess whether a path refers to a package directory."""
|
"""Guess whether a path refers to a package directory."""
|
||||||
|
warnings.warn('The pydoc.ispackage() function is deprecated',
|
||||||
|
DeprecationWarning, stacklevel=2)
|
||||||
if os.path.isdir(path):
|
if os.path.isdir(path):
|
||||||
for ext in ('.py', '.pyc'):
|
for ext in ('.py', '.pyc'):
|
||||||
if os.path.isfile(os.path.join(path, '__init__' + ext)):
|
if os.path.isfile(os.path.join(path, '__init__' + ext)):
|
||||||
|
|
|
@ -745,14 +745,18 @@ class PydocDocTest(unittest.TestCase):
|
||||||
|
|
||||||
def test_is_package_when_not_package(self):
|
def test_is_package_when_not_package(self):
|
||||||
with os_helper.temp_cwd() as test_dir:
|
with os_helper.temp_cwd() as test_dir:
|
||||||
self.assertFalse(pydoc.ispackage(test_dir))
|
with self.assertWarns(DeprecationWarning) as cm:
|
||||||
|
self.assertFalse(pydoc.ispackage(test_dir))
|
||||||
|
self.assertEqual(cm.filename, __file__)
|
||||||
|
|
||||||
def test_is_package_when_is_package(self):
|
def test_is_package_when_is_package(self):
|
||||||
with os_helper.temp_cwd() as test_dir:
|
with os_helper.temp_cwd() as test_dir:
|
||||||
init_path = os.path.join(test_dir, '__init__.py')
|
init_path = os.path.join(test_dir, '__init__.py')
|
||||||
open(init_path, 'w').close()
|
open(init_path, 'w').close()
|
||||||
self.assertTrue(pydoc.ispackage(test_dir))
|
with self.assertWarns(DeprecationWarning) as cm:
|
||||||
|
self.assertTrue(pydoc.ispackage(test_dir))
|
||||||
os.remove(init_path)
|
os.remove(init_path)
|
||||||
|
self.assertEqual(cm.filename, __file__)
|
||||||
|
|
||||||
def test_allmethods(self):
|
def test_allmethods(self):
|
||||||
# issue 17476: allmethods was no longer returning unbound methods.
|
# issue 17476: allmethods was no longer returning unbound methods.
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
The :func:`!pydoc.ispackage` function has been deprecated.
|
Loading…
Add table
Add a link
Reference in a new issue