mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
SF bug #460020: bug or feature: unicode() and subclasses.
Given an immutable type M, and an instance I of a subclass of M, the constructor call M(I) was just returning I as-is; but it should return a new instance of M. This fixes it for M in {int, long}. Strings, floats and tuples remain to be done. Added new macros PyInt_CheckExact and PyLong_CheckExact, to more easily distinguish between "is" and "is a" (i.e., only an int passes PyInt_CheckExact, while any sublass of int passes PyInt_Check). Added private API function _PyLong_Copy.
This commit is contained in:
parent
8b4e43e768
commit
64b5ce3a69
6 changed files with 55 additions and 3 deletions
|
@ -28,6 +28,7 @@ typedef struct {
|
|||
extern DL_IMPORT(PyTypeObject) PyInt_Type;
|
||||
|
||||
#define PyInt_Check(op) PyObject_TypeCheck(op, &PyInt_Type)
|
||||
#define PyInt_CheckExact(op) ((op)->ob_type == &PyInt_Type)
|
||||
|
||||
extern DL_IMPORT(PyObject *) PyInt_FromString(char*, char**, int);
|
||||
#ifdef Py_USING_UNICODE
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue