Skip to content

Commit 0b64714

Browse files
gh-116349: Deprecate platform.java_ver function (#116471)
Co-authored-by: Alex Waygood <[email protected]>
1 parent 4d95273 commit 0b64714

File tree

5 files changed

+26
-4
lines changed

5 files changed

+26
-4
lines changed

Doc/library/platform.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,10 @@ Java Platform
196196
``(os_name, os_version, os_arch)``. Values which cannot be determined are set to
197197
the defaults given as parameters (which all default to ``''``).
198198

199+
.. deprecated-removed:: 3.13 3.15
200+
It was largely untested, had a confusing API,
201+
and was only useful for Jython support.
202+
199203

200204
Windows Platform
201205
----------------

Doc/whatsnew/3.13.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -814,6 +814,10 @@ Deprecated
814814
* The undocumented and unused ``tarfile`` attribute of :class:`tarfile.TarFile`
815815
is deprecated and scheduled for removal in Python 3.16.
816816

817+
* :func:`platform.java_ver` is deprecated and will be removed in 3.15.
818+
It was largely untested, had a confusing API,
819+
and was only useful for Jython support.
820+
(Contributed by Nikita Sobolev in :gh:`116349`.)
817821

818822
Pending Removal in Python 3.14
819823
------------------------------
@@ -973,6 +977,11 @@ Pending Removal in Python 3.15
973977
They will be removed in Python 3.15.
974978
(Contributed by Victor Stinner in :gh:`105096`.)
975979

980+
* :func:`platform.java_ver` is deprecated and will be removed in 3.15.
981+
It was largely untested, had a confusing API,
982+
and was only useful for Jython support.
983+
(Contributed by Nikita Sobolev in :gh:`116349`.)
984+
976985
Pending Removal in Python 3.16
977986
------------------------------
978987

Lib/platform.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ def mac_ver(release='', versioninfo=('', '', ''), machine=''):
503503
return release, versioninfo, machine
504504

505505
def _java_getprop(name, default):
506-
506+
"""This private helper is deprecated in 3.13 and will be removed in 3.15"""
507507
from java.lang import System
508508
try:
509509
value = System.getProperty(name)
@@ -525,6 +525,8 @@ def java_ver(release='', vendor='', vminfo=('', '', ''), osinfo=('', '', '')):
525525
given as parameters (which all default to '').
526526
527527
"""
528+
import warnings
529+
warnings._deprecated('java_ver', remove=(3, 15))
528530
# Import the needed APIs
529531
try:
530532
import java.lang

Lib/test/test_platform.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -318,9 +318,13 @@ def raises_oserror(*a):
318318
platform._uname_cache = None
319319

320320
def test_java_ver(self):
321-
res = platform.java_ver()
322-
if sys.platform == 'java': # Is never actually checked in CI
323-
self.assertTrue(all(res))
321+
import re
322+
msg = re.escape(
323+
"'java_ver' is deprecated and slated for removal in Python 3.15"
324+
)
325+
with self.assertWarnsRegex(DeprecationWarning, msg):
326+
res = platform.java_ver()
327+
self.assertEqual(len(res), 4)
324328

325329
def test_win32_ver(self):
326330
res = platform.win32_ver()
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
:func:`platform.java_ver` is deprecated and will be removed in 3.15.
2+
It was largely untested, had a confusing API,
3+
and was only useful for Jython support.

0 commit comments

Comments
 (0)