Skip to content

Commit

Permalink
Merge branch 'main' into fast_range_v2
Browse files Browse the repository at this point in the history
  • Loading branch information
eendebakpt authored Mar 8, 2024
2 parents cbbf211 + 7cee276 commit b59002c
Show file tree
Hide file tree
Showing 14 changed files with 94 additions and 27 deletions.
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
2 changes: 1 addition & 1 deletion Lib/collections/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@ def update(self, iterable=None, /, **kwds):
'''
# The regular dict.update() operation makes no sense here because the
# replace behavior results in the some of original untouched counts
# replace behavior results in some of the original untouched counts
# being mixed-in with all of the other counts for a mismash that
# doesn't have a straight-forward interpretation in most counting
# contexts. Instead, we implement straight-addition. Both the inputs
Expand Down
14 changes: 5 additions & 9 deletions Lib/platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,10 +370,7 @@ def win32_is_iot():

def win32_edition():
try:
try:
import winreg
except ImportError:
import _winreg as winreg
import winreg
except ImportError:
pass
else:
Expand Down Expand Up @@ -432,10 +429,7 @@ def _win32_ver(version, csd, ptype):
csd = 'SP' + csd[13:]

try:
try:
import winreg
except ImportError:
import _winreg as winreg
import winreg
except ImportError:
pass
else:
Expand Down Expand Up @@ -503,7 +497,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 +519,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.
2 changes: 1 addition & 1 deletion Modules/Setup.stdlib.in
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@
*shared*
@MODULE__TESTIMPORTMULTIPLE_TRUE@_testimportmultiple _testimportmultiple.c
@MODULE__TESTMULTIPHASE_TRUE@_testmultiphase _testmultiphase.c
@MODULE__TESTMULTIPHASE_TRUE@_testsinglephase _testsinglephase.c
@MODULE__TESTSINGLEPHASE_TRUE@_testsinglephase _testsinglephase.c
@MODULE__TESTEXTERNALINSPECTION_TRUE@_testexternalinspection _testexternalinspection.c
@MODULE__CTYPES_TEST_TRUE@_ctypes_test _ctypes/_ctypes_test.c

Expand Down
2 changes: 1 addition & 1 deletion Modules/arraymodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ BB_setitem(arrayobject *ap, Py_ssize_t i, PyObject *v)
if (!PyArg_Parse(v, "b;array item must be integer", &x))
return -1;
if (i >= 0)
((char *)ap->ob_item)[i] = x;
((unsigned char *)ap->ob_item)[i] = x;
return 0;
}

Expand Down
5 changes: 3 additions & 2 deletions Python/bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -4096,8 +4096,9 @@ dummy_func(
null = NULL;
}

tier2 op(_CHECK_FUNCTION, (func/4 -- )) {
DEOPT_IF(frame->f_funcobj != func);
tier2 op(_CHECK_FUNCTION, (func_version/2 -- )) {
assert(PyFunction_Check(frame->f_funcobj));
DEOPT_IF(((PyFunctionObject *)frame->f_funcobj)->func_version != func_version);
}

/* Internal -- for testing executors */
Expand Down
5 changes: 3 additions & 2 deletions Python/executor_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Python/getargs.c
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
switch (c) {

case 'b': { /* unsigned byte -- very short int */
char *p = va_arg(*p_va, char *);
unsigned char *p = va_arg(*p_va, unsigned char *);
long ival = PyLong_AsLong(arg);
if (ival == -1 && PyErr_Occurred())
RETURN_ERR_OCCURRED;
Expand All @@ -633,7 +633,7 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,

case 'B': {/* byte sized bitfield - both signed and unsigned
values allowed */
char *p = va_arg(*p_va, char *);
unsigned char *p = va_arg(*p_va, unsigned char *);
unsigned long ival = PyLong_AsUnsignedLongMask(arg);
if (ival == (unsigned long)-1 && PyErr_Occurred())
RETURN_ERR_OCCURRED;
Expand Down
16 changes: 10 additions & 6 deletions Python/optimizer_analysis.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,11 @@ remove_globals(_PyInterpreterFrame *frame, _PyUOpInstruction *buffer,
return 1;
}
PyObject *globals = frame->f_globals;
assert(PyFunction_Check(((PyFunctionObject *)frame->f_funcobj)));
assert(((PyFunctionObject *)frame->f_funcobj)->func_builtins == builtins);
assert(((PyFunctionObject *)frame->f_funcobj)->func_globals == globals);
PyFunctionObject *function = (PyFunctionObject *)frame->f_funcobj;
assert(PyFunction_Check(function));
assert(function->func_builtins == builtins);
assert(function->func_globals == globals);
uint32_t function_version = _PyFunction_GetVersionForCurrentState(function);
/* In order to treat globals as constants, we need to
* know that the globals dict is the one we expected, and
* that it hasn't changed
Expand Down Expand Up @@ -181,7 +183,7 @@ remove_globals(_PyInterpreterFrame *frame, _PyUOpInstruction *buffer,
}
else {
buffer[pc].opcode = _CHECK_FUNCTION;
buffer[pc].operand = (uintptr_t)builtins;
buffer[pc].operand = function_version;
function_checked |= 1;
}
break;
Expand All @@ -203,7 +205,7 @@ remove_globals(_PyInterpreterFrame *frame, _PyUOpInstruction *buffer,
}
else {
buffer[pc].opcode = _CHECK_FUNCTION;
buffer[pc].operand = (uintptr_t)globals;
buffer[pc].operand = function_version;
function_checked |= 1;
}
break;
Expand All @@ -227,7 +229,8 @@ remove_globals(_PyInterpreterFrame *frame, _PyUOpInstruction *buffer,
return 1;
}
assert(PyFunction_Check(func));
if (prechecked_function_version == func->func_version) {
function_version = func->func_version;
if (prechecked_function_version == function_version) {
function_checked |= 1;
}
prechecked_function_version = 0;
Expand All @@ -245,6 +248,7 @@ remove_globals(_PyInterpreterFrame *frame, _PyUOpInstruction *buffer,
function_checked >>= 1;
PyFunctionObject *func = (PyFunctionObject *)buffer[pc].operand;
assert(PyFunction_Check(func));
function_version = func->func_version;
globals = func->func_globals;
builtins = func->func_builtins;
break;
Expand Down
44 changes: 44 additions & 0 deletions configure

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -7628,6 +7628,7 @@ PY_STDLIB_MOD([_testinternalcapi], [test "$TEST_MODULES" = yes])
PY_STDLIB_MOD([_testbuffer], [test "$TEST_MODULES" = yes])
PY_STDLIB_MOD([_testimportmultiple], [test "$TEST_MODULES" = yes], [test "$ac_cv_func_dlopen" = yes])
PY_STDLIB_MOD([_testmultiphase], [test "$TEST_MODULES" = yes], [test "$ac_cv_func_dlopen" = yes])
PY_STDLIB_MOD([_testsinglephase], [test "$TEST_MODULES" = yes], [test "$ac_cv_func_dlopen" = yes])
PY_STDLIB_MOD([_testexternalinspection], [test "$TEST_MODULES" = yes])
PY_STDLIB_MOD([xxsubtype], [test "$TEST_MODULES" = yes])
PY_STDLIB_MOD([_xxtestfuzz], [test "$TEST_MODULES" = yes])
Expand Down

0 comments on commit b59002c

Please sign in to comment.