Thanks to visit codestin.com
Credit goes to github.com

Skip to content

gh-116349: Deprecate platform.java_ver function #116471

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Doc/library/platform.rst
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,10 @@ Java Platform
``(os_name, os_version, os_arch)``. Values which cannot be determined are set to
the defaults given as parameters (which all default to ``''``).

.. deprecated-removed:: 3.13 3.15
It was largely untested, had a confusing API,
and was only useful for Jython support.


Windows Platform
----------------
Expand Down
9 changes: 9 additions & 0 deletions Doc/whatsnew/3.13.rst
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,10 @@ Deprecated
* The undocumented and unused ``tarfile`` attribute of :class:`tarfile.TarFile`
is deprecated and scheduled for removal in Python 3.16.

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

Pending Removal in Python 3.14
------------------------------
Expand Down Expand Up @@ -973,6 +977,11 @@ Pending Removal in Python 3.15
They will be removed in Python 3.15.
(Contributed by Victor Stinner in :gh:`105096`.)

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

Pending Removal in Python 3.16
------------------------------

Expand Down
4 changes: 3 additions & 1 deletion Lib/platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ def mac_ver(release='', versioninfo=('', '', ''), machine=''):
return release, versioninfo, machine

def _java_getprop(name, default):

"""This private helper is deprecated in 3.13 and will be removed in 3.15"""
from java.lang import System
try:
value = System.getProperty(name)
Expand All @@ -525,6 +525,8 @@ def java_ver(release='', vendor='', vminfo=('', '', ''), osinfo=('', '', '')):
given as parameters (which all default to '').

"""
import warnings
warnings._deprecated('java_ver', remove=(3, 15))
# Import the needed APIs
try:
import java.lang
Expand Down
10 changes: 7 additions & 3 deletions Lib/test/test_platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,13 @@ def raises_oserror(*a):
platform._uname_cache = None

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

def test_win32_ver(self):
res = platform.win32_ver()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
:func:`platform.java_ver` is deprecated and will be removed in 3.15.
It was largely untested, had a confusing API,
and was only useful for Jython support.