This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: xxlimited.c XxoObject_Check should be XxoObject_CheckExact
Type: enhancement Stage: resolved
Components: Extension Modules Versions: Python 3.10
process
Status: closed Resolution: postponed
Dependencies: Superseder:
Assigned To: Nosy List: Jim.Jewett, petr.viktorin, shihai1991, vstinner
Priority: normal Keywords: easy

Created on 2017-07-18 21:17 by Jim.Jewett, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (4)
msg298617 - (view) Author: Jim Jewett (Jim.Jewett) * (Python triager) Date: 2017-07-18 21:17
https://github.com/python/cpython/blob/master/Modules/xxlimited.c#L28

#define XxoObject_Check(v)      (Py_TYPE(v) == Xxo_Type)

assumes that the type cannot be subclassed, but does not say so.  Since this is demo code, it would be better to use something like decimal:

#define PyDec_CheckExact(v) (Py_TYPE(v) == &PyDec_Type)
#define PyDec_Check(v) PyObject_TypeCheck(v, &PyDec_Type)

I *believe* (but haven't verified) that would be:

#define XxoObject_CheckExact(v) (Py_TYPE(v) == &Xxo_Type)
#define XxoObject_Check(v) PyObject_TypeCheck(v, &Xxo_Type)
msg383906 - (view) Author: Hai Shi (shihai1991) * (Python triager) Date: 2020-12-28 17:19
> #define XxoObject_CheckExact(v) (Py_TYPE(v) == &Xxo_Type)
`#define Xxo_CheckExact(obj) Py_IS_TYPE(obj, &Xxo_Type)` would be better to hide details now.

> #define XxoObject_Check(v) PyObject_TypeCheck(v, &Xxo_Type)
+1

I think the annotation will worth to be updaetd.
https://github.com/python/cpython/blob/master/Modules/xxlimited.c#L76
msg384124 - (view) Author: Petr Viktorin (petr.viktorin) * (Python committer) Date: 2020-12-31 15:26
The Check code is now commented out, and the issue of type checking is mentioned in PEP 630.
(The xxlimited_35 module still contains XxoObject_Check, among other historical code.)
msg384154 - (view) Author: Hai Shi (shihai1991) * (Python triager) Date: 2021-01-01 07:49
>The Check code is now commented out, and the issue of type checking is mentioned in PEP 630.

Got it, thanks for your supplement :)
History
Date User Action Args
2022-04-11 14:58:49adminsetgithub: 75146
2021-01-01 07:49:53shihai1991setmessages: + msg384154
2020-12-31 15:26:05petr.viktorinsetstatus: open -> closed
resolution: postponed
messages: + msg384124

stage: needs patch -> resolved
2020-12-28 17:19:24shihai1991setversions: + Python 3.10, - Python 3.7
nosy: + petr.viktorin, vstinner, shihai1991

messages: + msg383906

keywords: + easy
2017-07-18 21:17:58Jim.Jewettcreate