Skip to content

Commit 462d636

Browse files
Merge branch 'main' into argparse-suggest-default
2 parents 55b4f0c + d51be28 commit 462d636

File tree

5 files changed

+24
-6
lines changed

5 files changed

+24
-6
lines changed

Include/internal/pycore_stackref.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,12 @@ PyStackRef_IsError(_PyStackRef ref)
296296
return ref.bits == Py_TAG_INVALID;
297297
}
298298

299+
static inline bool
300+
PyStackRef_IsMalformed(_PyStackRef ref)
301+
{
302+
return (ref.bits & Py_TAG_BITS) == Py_TAG_INVALID;
303+
}
304+
299305
static inline bool
300306
PyStackRef_IsValid(_PyStackRef ref)
301307
{

Modules/_dbmmodule.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,8 +515,12 @@ dbm__enter__(PyObject *self, PyObject *Py_UNUSED(dummy))
515515
static PyObject *
516516
dbm__exit__(PyObject *self, PyObject *Py_UNUSED(args))
517517
{
518+
PyObject *result;
518519
dbmobject *dp = dbmobject_CAST(self);
519-
return _dbm_dbm_close_impl(dp);
520+
Py_BEGIN_CRITICAL_SECTION(self);
521+
result = _dbm_dbm_close_impl(dp);
522+
Py_END_CRITICAL_SECTION();
523+
return result;
520524
}
521525

522526
static PyMethodDef dbm_methods[] = {

Modules/_gdbmmodule.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,11 @@ gdbm__enter__(PyObject *self, PyObject *args)
690690
static PyObject *
691691
gdbm__exit__(PyObject *self, PyObject *args)
692692
{
693-
return _gdbm_gdbm_close_impl((gdbmobject *)self);
693+
PyObject *result;
694+
Py_BEGIN_CRITICAL_SECTION(self);
695+
result = _gdbm_gdbm_close_impl((gdbmobject *)self);
696+
Py_END_CRITICAL_SECTION();
697+
return result;
694698
}
695699

696700
static PyMethodDef gdbm_methods[] = {

Modules/posixmodule.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3396,10 +3396,10 @@ STATX_GET_UINT(stx_atomic_write_unit_max_opt, STATX_WRITE_ATOMIC)
33963396
STATX_GET_ULONGLONG(stx_blocks, STATX_BLOCKS)
33973397
STATX_GET_ULONGLONG(stx_ino, STATX_INO)
33983398
STATX_GET_ULONGLONG(stx_size, STATX_SIZE)
3399-
#ifdef HAVE_STRUCT_STATX_STX_MNT_ID
3399+
#if defined(STATX_MNT_ID) && defined(HAVE_STRUCT_STATX_STX_MNT_ID)
34003400
STATX_GET_ULONGLONG(stx_mnt_id, STATX_MNT_ID)
34013401
#endif
3402-
#ifdef HAVE_STRUCT_STATX_STX_SUBVOL
3402+
#if defined(STATX_SUBVOL) && defined(HAVE_STRUCT_STATX_STX_SUBVOL)
34033403
STATX_GET_ULONGLONG(stx_subvol, STATX_SUBVOL)
34043404
#endif
34053405

@@ -3458,14 +3458,14 @@ static PyGetSetDef pystatx_result_getset[] = {
34583458
G(stx_ctime_ns, "time of last change in nanoseconds"),
34593459
G(stx_mtime, "time of last modification"),
34603460
G(stx_mtime_ns, "time of last modification in nanoseconds"),
3461-
#ifdef HAVE_STRUCT_STATX_STX_MNT_ID
3461+
#if defined(STATX_MNT_ID) && defined(HAVE_STRUCT_STATX_STX_MNT_ID)
34623462
G(stx_mnt_id, "mount ID"),
34633463
#endif
34643464
#ifdef HAVE_STRUCT_STATX_STX_DIO_MEM_ALIGN
34653465
G(stx_dio_mem_align, "direct I/O memory buffer alignment"),
34663466
G(stx_dio_offset_align, "direct I/O file offset alignment"),
34673467
#endif
3468-
#ifdef HAVE_STRUCT_STATX_STX_SUBVOL
3468+
#if defined(STATX_SUBVOL) && defined(HAVE_STRUCT_STATX_STX_SUBVOL)
34693469
G(stx_subvol, "subvolume ID"),
34703470
#endif
34713471
#ifdef HAVE_STRUCT_STATX_STX_ATOMIC_WRITE_UNIT_MIN

Python/ceval.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@ dump_item(_PyStackRef item)
160160
printf("<NULL>");
161161
return;
162162
}
163+
if (PyStackRef_IsMalformed(item)) {
164+
printf("<INVALID>");
165+
return;
166+
}
163167
if (PyStackRef_IsTaggedInt(item)) {
164168
printf("%" PRId64, (int64_t)PyStackRef_UntagInt(item));
165169
return;

0 commit comments

Comments
 (0)