Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Address code review
  • Loading branch information
corona10 committed Nov 12, 2024
commit 30020b9f80a135ad704c1102f02d473afe08faad
9 changes: 7 additions & 2 deletions Include/internal/pycore_typeobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,14 @@ extern unsigned int _PyType_GetVersionForCurrentState(PyTypeObject *tp);
PyAPI_FUNC(void) _PyType_SetVersion(PyTypeObject *tp, unsigned int version);
PyTypeObject *_PyType_LookupByVersion(unsigned int version);

// Returns 0 on success or caller-specific error on failure.
// Function pointer type for user-defined validation function that will be
// called by _PyType_Validate().
// It should return 0 if the validation is passed, otherwise it will return -1.
typedef int (*_py_validate_type)(PyTypeObject *);
// Returns 0 on success, -1 if no type version could be assigned, or the error returned by validate

// It will verify the ``ty`` through user-defined validation function ``validate``,
// and if the validation is passed, it will set the ``tp_version`` to the next
// available version and return 0. Otherwise, it will return an error code.
Comment thread
mpage marked this conversation as resolved.
Outdated
extern int _PyType_Validate(PyTypeObject *ty, _py_validate_type validate, unsigned int *tp_version);

#ifdef __cplusplus
Expand Down
4 changes: 0 additions & 4 deletions Python/specialize.c
Original file line number Diff line number Diff line change
Expand Up @@ -2749,10 +2749,6 @@ _Py_Specialize_ToBool(_PyStackRef value_o, _Py_CODEUNIT *instr)
}

assert(err == 0);
if (version == 0) {
unspecialize(instr, SPEC_FAIL_OUT_OF_VERSIONS);
return;
}
assert(version);
write_u32(cache->version, version);
specialize(instr, TO_BOOL_ALWAYS_TRUE);
Expand Down