summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
Diffstat (limited to 'Lib')
-rwxr-xr-xLib/platform.py19
-rw-r--r--Lib/test/test_platform.py24
2 files changed, 35 insertions, 8 deletions
diff --git a/Lib/platform.py b/Lib/platform.py
index b1c659e..52a009a 100755
--- a/Lib/platform.py
+++ b/Lib/platform.py
@@ -297,6 +297,15 @@ def linux_distribution(distname='', version='', id='',
supported_dists=_supported_dists,
full_distribution_name=1):
+ import warnings
+ warnings.warn("dist() and linux_distribution() functions are deprecated "
+ "in Python 3.5 and will be removed in Python 3.7",
+ PendingDeprecationWarning, stacklevel=2)
+ return _linux_distribution(distname, version, id, supported_dists,
+ full_distribution_name)
+
+def _linux_distribution(distname, version, id, supported_dists,
+ full_distribution_name):
""" Tries to determine the name of the Linux OS distribution name.
@@ -363,9 +372,13 @@ def dist(distname='', version='', id='',
args given as parameters.
"""
- return linux_distribution(distname, version, id,
- supported_dists=supported_dists,
- full_distribution_name=0)
+ import warnings
+ warnings.warn("dist() and linux_distribution() functions are deprecated "
+ "in Python 3.5 and will be removed in Python 3.7",
+ PendingDeprecationWarning, stacklevel=2)
+ return _linux_distribution(distname, version, id,
+ supported_dists=supported_dists,
+ full_distribution_name=0)
def popen(cmd, mode='r', bufsize=-1):
diff --git a/Lib/test/test_platform.py b/Lib/test/test_platform.py
index ededbdb..f4ce36d 100644
--- a/Lib/test/test_platform.py
+++ b/Lib/test/test_platform.py
@@ -311,10 +311,24 @@ class PlatformTest(unittest.TestCase):
self.assertEqual(version, '19')
self.assertEqual(distid, 'Schr\xf6dinger\u2019s Cat')
-def test_main():
- support.run_unittest(
- PlatformTest
- )
+
+class DeprecationTest(unittest.TestCase):
+
+ def test_dist_deprecation(self):
+ with self.assertWarns(PendingDeprecationWarning) as cm:
+ platform.dist()
+ self.assertEqual(str(cm.warning),
+ 'dist() and linux_distribution() functions are '
+ 'deprecated in Python 3.5 and will be removed in '
+ 'Python 3.7')
+
+ def test_linux_distribution_deprecation(self):
+ with self.assertWarns(PendingDeprecationWarning) as cm:
+ platform.linux_distribution()
+ self.assertEqual(str(cm.warning),
+ 'dist() and linux_distribution() functions are '
+ 'deprecated in Python 3.5 and will be removed in '
+ 'Python 3.7')
if __name__ == '__main__':
- test_main()
+ unittest.main()