Skip to content

Commit 4c83848

Browse files
committed
handle tagged ints when doing type checks
1 parent 428735b commit 4c83848

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Include/internal/pycore_stackref.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -714,18 +714,27 @@ PyStackRef_TYPE(_PyStackRef stackref) {
714714
static inline bool
715715
PyStackRef_GenCheck(_PyStackRef stackref)
716716
{
717+
if (PyStackRef_IsTaggedInt(stackref)) {
718+
return false;
719+
}
717720
return PyGen_Check(PyStackRef_AsPyObjectBorrow(stackref));
718721
}
719722

720723
static inline bool
721724
PyStackRef_BoolCheck(_PyStackRef stackref)
722725
{
726+
if (PyStackRef_IsTaggedInt(stackref)) {
727+
return false;
728+
}
723729
return PyBool_Check(PyStackRef_AsPyObjectBorrow(stackref));
724730
}
725731

726732
static inline bool
727733
PyStackRef_LongCheck(_PyStackRef stackref)
728734
{
735+
if (PyStackRef_IsTaggedInt(stackref)) {
736+
return false;
737+
}
729738
return PyLong_Check(PyStackRef_AsPyObjectBorrow(stackref));
730739
}
731740

@@ -738,12 +747,18 @@ PyStackRef_ExceptionInstanceCheck(_PyStackRef stackref)
738747
static inline bool
739748
PyStackRef_CodeCheck(_PyStackRef stackref)
740749
{
750+
if (PyStackRef_IsTaggedInt(stackref)) {
751+
return false;
752+
}
741753
return PyCode_Check(PyStackRef_AsPyObjectBorrow(stackref));
742754
}
743755

744756
static inline bool
745757
PyStackRef_FunctionCheck(_PyStackRef stackref)
746758
{
759+
if (PyStackRef_IsTaggedInt(stackref)) {
760+
return false;
761+
}
747762
return PyFunction_Check(PyStackRef_AsPyObjectBorrow(stackref));
748763
}
749764

0 commit comments

Comments
 (0)