[issue15870] PyType_FromSpec should take metaclass as an argument
Sebastian Berg
report at bugs.python.org
Tue Sep 28 13:01:34 EDT 2021
Sebastian Berg <sebastian at sipsolutions.net> added the comment:
Just to note, that there are two – somewhat distinct – issues here in my opinion:
1. `FromSpec` does not scan `bases` for the correct metaclass, which it could; this could even be considered a bug?
2. You cannot pass in a desired metaclass, which may require a new API function.
My patch tries to address the first (the class creator has to take care that this is reasonable for the metaclass). I had hoped the `slot` mechanism can avoid the API discussion for the second one, but I guess not.
On the discussion on `tp_type/meta` being incorrect usage:
I am slightly surprised we actually care about static C-definitions?
There is no reason that a `spec` should be declared static (aside that you have to move it into the function otherwise)? Everything is copied by `_FromSpec` after all.
However, I suppose that would replace a safe-by-design API with a "best practice" to never define the spec/slots statically (a best practice that is probably not generally followed or even advertised currently, I guess).
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue15870>
_______________________________________
More information about the Python-bugs-list
mailing list