Skip to content

Commit 30020b9

Browse files
committed
Address code review
1 parent 23e190e commit 30020b9

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

Include/internal/pycore_typeobject.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,9 +269,14 @@ extern unsigned int _PyType_GetVersionForCurrentState(PyTypeObject *tp);
269269
PyAPI_FUNC(void) _PyType_SetVersion(PyTypeObject *tp, unsigned int version);
270270
PyTypeObject *_PyType_LookupByVersion(unsigned int version);
271271

272-
// Returns 0 on success or caller-specific error on failure.
272+
// Function pointer type for user-defined validation function that will be
273+
// called by _PyType_Validate().
274+
// It should return 0 if the validation is passed, otherwise it will return -1.
273275
typedef int (*_py_validate_type)(PyTypeObject *);
274-
// Returns 0 on success, -1 if no type version could be assigned, or the error returned by validate
276+
277+
// It will verify the ``ty`` through user-defined validation function ``validate``,
278+
// and if the validation is passed, it will set the ``tp_version`` to the next
279+
// available version and return 0. Otherwise, it will return an error code.
275280
extern int _PyType_Validate(PyTypeObject *ty, _py_validate_type validate, unsigned int *tp_version);
276281

277282
#ifdef __cplusplus

Python/specialize.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2749,10 +2749,6 @@ _Py_Specialize_ToBool(_PyStackRef value_o, _Py_CODEUNIT *instr)
27492749
}
27502750

27512751
assert(err == 0);
2752-
if (version == 0) {
2753-
unspecialize(instr, SPEC_FAIL_OUT_OF_VERSIONS);
2754-
return;
2755-
}
27562752
assert(version);
27572753
write_u32(cache->version, version);
27582754
specialize(instr, TO_BOOL_ALWAYS_TRUE);

0 commit comments

Comments
 (0)