Skip to content

gh-133604: remove deprecated java_ver function #133888

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 14 commits into from
May 16, 2025
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
2 changes: 1 addition & 1 deletion Doc/deprecations/pending-removal-in-3.15.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Pending removal in Python 3.15

* :mod:`platform`:

* :func:`~platform.java_ver` has been deprecated since Python 3.13.
* :func:`!platform.java_ver` has been deprecated since Python 3.13.
This function is only useful for Jython support, has a confusing API,
and is largely untested.

Expand Down
18 changes: 0 additions & 18 deletions Doc/library/platform.rst
Original file line number Diff line number Diff line change
Expand Up @@ -188,24 +188,6 @@ Cross platform
:attr:`processor` is resolved late instead of immediately.


Java platform
-------------


.. function:: java_ver(release='', vendor='', vminfo=('','',''), osinfo=('','',''))

Version interface for Jython.

Returns a tuple ``(release, vendor, vminfo, osinfo)`` with *vminfo* being a
tuple ``(vm_name, vm_release, vm_vendor)`` and *osinfo* being a tuple
``(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
2 changes: 1 addition & 1 deletion Doc/whatsnew/3.13.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1908,7 +1908,7 @@ New Deprecations

* :mod:`platform`:

* Deprecate :func:`~platform.java_ver`,
* Deprecate :func:`!platform.java_ver`,
to be removed in Python 3.15.
This function is only useful for Jython support, has a confusing API,
and is largely untested.
Expand Down
8 changes: 8 additions & 0 deletions Doc/whatsnew/3.15.rst
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,14 @@ Deprecated
Removed
=======

platform
--------

* Removed the :func:`!platform.java_ver` function,
which was deprecated since Python 3.13.
(Contributed by Alexey Makridenko in :gh:`133604`.)


sysconfig
---------

Expand Down
67 changes: 2 additions & 65 deletions Lib/platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#
# History:
#
# <see CVS and SVN checkin messages for history>
# <see checkin messages for history>
#
# 1.0.9 - added invalidate_caches() function to invalidate cached values
# 1.0.8 - changed Windows support to read version from kernel32.dll
Expand Down Expand Up @@ -110,7 +110,7 @@

"""

__version__ = '1.0.9'
__version__ = '1.1.0'

import collections
import os
Expand Down Expand Up @@ -528,53 +528,6 @@ def ios_ver(system="", release="", model="", is_simulator=False):
return IOSVersionInfo(system, release, model, is_simulator)


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)
if value is None:
return default
return value
except AttributeError:
return default

def java_ver(release='', vendor='', vminfo=('', '', ''), osinfo=('', '', '')):

""" Version interface for Jython.

Returns a tuple (release, vendor, vminfo, osinfo) with vminfo being
a tuple (vm_name, vm_release, vm_vendor) and osinfo being a
tuple (os_name, os_version, os_arch).

Values which cannot be determined are set to the defaults
given as parameters (which all default to '').

"""
import warnings
warnings._deprecated('java_ver', remove=(3, 15))
# Import the needed APIs
try:
import java.lang # noqa: F401
except ImportError:
return release, vendor, vminfo, osinfo

vendor = _java_getprop('java.vendor', vendor)
release = _java_getprop('java.version', release)
vm_name, vm_release, vm_vendor = vminfo
vm_name = _java_getprop('java.vm.name', vm_name)
vm_vendor = _java_getprop('java.vm.vendor', vm_vendor)
vm_release = _java_getprop('java.vm.version', vm_release)
vminfo = vm_name, vm_release, vm_vendor
os_name, os_version, os_arch = osinfo
os_arch = _java_getprop('java.os.arch', os_arch)
os_name = _java_getprop('java.os.name', os_name)
os_version = _java_getprop('java.os.version', os_version)
osinfo = os_name, os_version, os_arch

return release, vendor, vminfo, osinfo


AndroidVer = collections.namedtuple(
"AndroidVer", "release api_level manufacturer model device is_emulator")

Expand Down Expand Up @@ -1034,13 +987,6 @@ def uname():
version = '16bit'
system = 'Windows'

elif system[:4] == 'java':
release, vendor, vminfo, osinfo = java_ver()
system = 'Java'
version = ', '.join(vminfo)
if not version:
version = vendor

# System specific extensions
if system == 'OpenVMS':
# OpenVMS seems to have release and version mixed up
Expand Down Expand Up @@ -1370,15 +1316,6 @@ def platform(aliased=False, terse=False):
platform = _platform(system, release, machine, processor,
'with',
libcname+libcversion)
elif system == 'Java':
# Java platforms
r, v, vminfo, (os_name, os_version, os_arch) = java_ver()
if terse or not os_name:
platform = _platform(system, release, version)
else:
platform = _platform(system, release, version,
'on',
os_name, os_version, os_arch)

else:
# Generic handler
Expand Down
9 changes: 0 additions & 9 deletions Lib/test/test_platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,15 +383,6 @@ def raises_oserror(*a):
finally:
platform._uname_cache = None

def test_java_ver(self):
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)

@unittest.skipUnless(support.MS_WINDOWS, 'This test only makes sense on Windows')
def test_win32_ver(self):
release1, version1, csd1, ptype1 = 'a', 'b', 'c', 'd'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove :func:`!platform.java_ver` which was deprecated since Python 3.13.
Loading