aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Modules
diff options
context:
space:
mode:
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_heapqmodule.c6
-rw-r--r--Modules/_localemodule.c2
-rw-r--r--Modules/_testcapi/abstract.c38
-rw-r--r--Modules/_testcapi/vectorcall.c8
-rw-r--r--Modules/getpath.py11
5 files changed, 50 insertions, 15 deletions
diff --git a/Modules/_heapqmodule.c b/Modules/_heapqmodule.c
index 560fe431fca..05d01acd771 100644
--- a/Modules/_heapqmodule.c
+++ b/Modules/_heapqmodule.c
@@ -463,11 +463,11 @@ siftup_max(PyListObject *heap, Py_ssize_t pos)
return -1;
}
- /* Bubble up the smaller child until hitting a leaf. */
+ /* Bubble up the larger child until hitting a leaf. */
arr = _PyList_ITEMS(heap);
limit = endpos >> 1; /* smallest pos that has no child */
while (pos < limit) {
- /* Set childpos to index of smaller child. */
+ /* Set childpos to index of larger child. */
childpos = 2*pos + 1; /* leftmost child position */
if (childpos + 1 < endpos) {
PyObject* a = arr[childpos + 1];
@@ -487,7 +487,7 @@ siftup_max(PyListObject *heap, Py_ssize_t pos)
return -1;
}
}
- /* Move the smaller child up. */
+ /* Move the larger child up. */
tmp1 = arr[childpos];
tmp2 = arr[pos];
FT_ATOMIC_STORE_PTR_RELAXED(arr[childpos], tmp2);
diff --git a/Modules/_localemodule.c b/Modules/_localemodule.c
index c1f56008b7c..41e6d48b1db 100644
--- a/Modules/_localemodule.c
+++ b/Modules/_localemodule.c
@@ -692,7 +692,7 @@ _locale_nl_langinfo_impl(PyObject *module, int item)
result = result != NULL ? result : "";
char *oldloc = NULL;
if (langinfo_constants[i].category != LC_CTYPE
- && (
+ && *result && (
#ifdef __GLIBC__
// gh-133740: Always change the locale for ALT_DIGITS and ERA
# ifdef ALT_DIGITS
diff --git a/Modules/_testcapi/abstract.c b/Modules/_testcapi/abstract.c
index d4045afd515..c1f769456ac 100644
--- a/Modules/_testcapi/abstract.c
+++ b/Modules/_testcapi/abstract.c
@@ -178,6 +178,42 @@ sequence_fast_get_item(PyObject *self, PyObject *args)
}
+static PyObject *
+object_setattr_null_exc(PyObject *self, PyObject *args)
+{
+ PyObject *obj, *name, *exc;
+ if (!PyArg_ParseTuple(args, "OOO", &obj, &name, &exc)) {
+ return NULL;
+ }
+
+ PyErr_SetObject((PyObject*)Py_TYPE(exc), exc);
+ if (PyObject_SetAttr(obj, name, NULL) < 0) {
+ return NULL;
+ }
+ assert(PyErr_Occurred());
+ return NULL;
+}
+
+
+static PyObject *
+object_setattrstring_null_exc(PyObject *self, PyObject *args)
+{
+ PyObject *obj, *exc;
+ const char *name;
+ Py_ssize_t size;
+ if (!PyArg_ParseTuple(args, "Oz#O", &obj, &name, &size, &exc)) {
+ return NULL;
+ }
+
+ PyErr_SetObject((PyObject*)Py_TYPE(exc), exc);
+ if (PyObject_SetAttrString(obj, name, NULL) < 0) {
+ return NULL;
+ }
+ assert(PyErr_Occurred());
+ return NULL;
+}
+
+
static PyMethodDef test_methods[] = {
{"object_getoptionalattr", object_getoptionalattr, METH_VARARGS},
{"object_getoptionalattrstring", object_getoptionalattrstring, METH_VARARGS},
@@ -191,6 +227,8 @@ static PyMethodDef test_methods[] = {
{"sequence_fast_get_size", sequence_fast_get_size, METH_O},
{"sequence_fast_get_item", sequence_fast_get_item, METH_VARARGS},
+ {"object_setattr_null_exc", object_setattr_null_exc, METH_VARARGS},
+ {"object_setattrstring_null_exc", object_setattrstring_null_exc, METH_VARARGS},
{NULL},
};
diff --git a/Modules/_testcapi/vectorcall.c b/Modules/_testcapi/vectorcall.c
index 03aaacb328e..f89dcb6c4cf 100644
--- a/Modules/_testcapi/vectorcall.c
+++ b/Modules/_testcapi/vectorcall.c
@@ -179,14 +179,14 @@ _testcapi_VectorCallClass_set_vectorcall_impl(PyObject *self,
if (!PyObject_TypeCheck(self, type)) {
return PyErr_Format(
PyExc_TypeError,
- "expected %s instance",
- PyType_GetName(type));
+ "expected %N instance",
+ type);
}
if (!type->tp_vectorcall_offset) {
return PyErr_Format(
PyExc_TypeError,
- "type %s has no vectorcall offset",
- PyType_GetName(type));
+ "type %N has no vectorcall offset",
+ type);
}
*(vectorcallfunc*)((char*)self + type->tp_vectorcall_offset) = (
VectorCallClass_vectorcall);
diff --git a/Modules/getpath.py b/Modules/getpath.py
index be2210345af..b89d7427e3f 100644
--- a/Modules/getpath.py
+++ b/Modules/getpath.py
@@ -364,10 +364,9 @@ if not py_setpath:
venv_prefix = None
pyvenvcfg = []
- # Search for the 'home' key in pyvenv.cfg. Currently, we don't consider the
- # presence of a pyvenv.cfg file without a 'home' key to signify the
- # existence of a virtual environment — we quietly ignore them.
- # XXX: If we don't find a 'home' key, we don't look for another pyvenv.cfg!
+ # Search for the 'home' key in pyvenv.cfg. If a home key isn't found,
+ # then it means a venv is active and home is based on the venv's
+ # executable (if its a symlink, home is where the symlink points).
for line in pyvenvcfg:
key, had_equ, value = line.partition('=')
if had_equ and key.strip().lower() == 'home':
@@ -412,10 +411,8 @@ if not py_setpath:
if isfile(candidate):
base_executable = candidate
break
+ # home key found; stop iterating over lines
break
- else:
- # We didn't find a 'home' key in pyvenv.cfg (no break), reset venv_prefix.
- venv_prefix = None
# ******************************************************************************