Skip to content

Commit 7a4a6cf

Browse files
authored
gh-133604: remove deprecated java_ver function (#133888)
1 parent 62f66ca commit 7a4a6cf

File tree

7 files changed

+13
-94
lines changed

7 files changed

+13
-94
lines changed

Doc/deprecations/pending-removal-in-3.15.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Pending removal in Python 3.15
5151

5252
* :mod:`platform`:
5353

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

Doc/library/platform.rst

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -188,24 +188,6 @@ Cross platform
188188
:attr:`processor` is resolved late instead of immediately.
189189

190190

191-
Java platform
192-
-------------
193-
194-
195-
.. function:: java_ver(release='', vendor='', vminfo=('','',''), osinfo=('','',''))
196-
197-
Version interface for Jython.
198-
199-
Returns a tuple ``(release, vendor, vminfo, osinfo)`` with *vminfo* being a
200-
tuple ``(vm_name, vm_release, vm_vendor)`` and *osinfo* being a tuple
201-
``(os_name, os_version, os_arch)``. Values which cannot be determined are set to
202-
the defaults given as parameters (which all default to ``''``).
203-
204-
.. deprecated-removed:: 3.13 3.15
205-
It was largely untested, had a confusing API,
206-
and was only useful for Jython support.
207-
208-
209191
Windows platform
210192
----------------
211193

Doc/whatsnew/3.13.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1908,7 +1908,7 @@ New Deprecations
19081908

19091909
* :mod:`platform`:
19101910

1911-
* Deprecate :func:`~platform.java_ver`,
1911+
* Deprecate :func:`!platform.java_ver`,
19121912
to be removed in Python 3.15.
19131913
This function is only useful for Jython support, has a confusing API,
19141914
and is largely untested.

Doc/whatsnew/3.15.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,14 @@ Deprecated
121121
Removed
122122
=======
123123

124+
platform
125+
--------
126+
127+
* Removed the :func:`!platform.java_ver` function,
128+
which was deprecated since Python 3.13.
129+
(Contributed by Alexey Makridenko in :gh:`133604`.)
130+
131+
124132
sysconfig
125133
---------
126134

Lib/platform.py

Lines changed: 2 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#
3030
# History:
3131
#
32-
# <see CVS and SVN checkin messages for history>
32+
# <see checkin messages for history>
3333
#
3434
# 1.0.9 - added invalidate_caches() function to invalidate cached values
3535
# 1.0.8 - changed Windows support to read version from kernel32.dll
@@ -110,7 +110,7 @@
110110
111111
"""
112112

113-
__version__ = '1.0.9'
113+
__version__ = '1.1.0'
114114

115115
import collections
116116
import os
@@ -528,53 +528,6 @@ def ios_ver(system="", release="", model="", is_simulator=False):
528528
return IOSVersionInfo(system, release, model, is_simulator)
529529

530530

531-
def _java_getprop(name, default):
532-
"""This private helper is deprecated in 3.13 and will be removed in 3.15"""
533-
from java.lang import System
534-
try:
535-
value = System.getProperty(name)
536-
if value is None:
537-
return default
538-
return value
539-
except AttributeError:
540-
return default
541-
542-
def java_ver(release='', vendor='', vminfo=('', '', ''), osinfo=('', '', '')):
543-
544-
""" Version interface for Jython.
545-
546-
Returns a tuple (release, vendor, vminfo, osinfo) with vminfo being
547-
a tuple (vm_name, vm_release, vm_vendor) and osinfo being a
548-
tuple (os_name, os_version, os_arch).
549-
550-
Values which cannot be determined are set to the defaults
551-
given as parameters (which all default to '').
552-
553-
"""
554-
import warnings
555-
warnings._deprecated('java_ver', remove=(3, 15))
556-
# Import the needed APIs
557-
try:
558-
import java.lang # noqa: F401
559-
except ImportError:
560-
return release, vendor, vminfo, osinfo
561-
562-
vendor = _java_getprop('java.vendor', vendor)
563-
release = _java_getprop('java.version', release)
564-
vm_name, vm_release, vm_vendor = vminfo
565-
vm_name = _java_getprop('java.vm.name', vm_name)
566-
vm_vendor = _java_getprop('java.vm.vendor', vm_vendor)
567-
vm_release = _java_getprop('java.vm.version', vm_release)
568-
vminfo = vm_name, vm_release, vm_vendor
569-
os_name, os_version, os_arch = osinfo
570-
os_arch = _java_getprop('java.os.arch', os_arch)
571-
os_name = _java_getprop('java.os.name', os_name)
572-
os_version = _java_getprop('java.os.version', os_version)
573-
osinfo = os_name, os_version, os_arch
574-
575-
return release, vendor, vminfo, osinfo
576-
577-
578531
AndroidVer = collections.namedtuple(
579532
"AndroidVer", "release api_level manufacturer model device is_emulator")
580533

@@ -1034,13 +987,6 @@ def uname():
1034987
version = '16bit'
1035988
system = 'Windows'
1036989

1037-
elif system[:4] == 'java':
1038-
release, vendor, vminfo, osinfo = java_ver()
1039-
system = 'Java'
1040-
version = ', '.join(vminfo)
1041-
if not version:
1042-
version = vendor
1043-
1044990
# System specific extensions
1045991
if system == 'OpenVMS':
1046992
# OpenVMS seems to have release and version mixed up
@@ -1370,15 +1316,6 @@ def platform(aliased=False, terse=False):
13701316
platform = _platform(system, release, machine, processor,
13711317
'with',
13721318
libcname+libcversion)
1373-
elif system == 'Java':
1374-
# Java platforms
1375-
r, v, vminfo, (os_name, os_version, os_arch) = java_ver()
1376-
if terse or not os_name:
1377-
platform = _platform(system, release, version)
1378-
else:
1379-
platform = _platform(system, release, version,
1380-
'on',
1381-
os_name, os_version, os_arch)
13821319

13831320
else:
13841321
# Generic handler

Lib/test/test_platform.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -383,15 +383,6 @@ def raises_oserror(*a):
383383
finally:
384384
platform._uname_cache = None
385385

386-
def test_java_ver(self):
387-
import re
388-
msg = re.escape(
389-
"'java_ver' is deprecated and slated for removal in Python 3.15"
390-
)
391-
with self.assertWarnsRegex(DeprecationWarning, msg):
392-
res = platform.java_ver()
393-
self.assertEqual(len(res), 4)
394-
395386
@unittest.skipUnless(support.MS_WINDOWS, 'This test only makes sense on Windows')
396387
def test_win32_ver(self):
397388
release1, version1, csd1, ptype1 = 'a', 'b', 'c', 'd'
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Remove :func:`!platform.java_ver` which was deprecated since Python 3.13.

0 commit comments

Comments
 (0)