Message398751
| Author |
petr.viktorin |
| Recipients |
Alexander.Belopolsky, Arfrever, Robin.Schreiber, amaury.forgeotdarc, belopolsky, jcea, jhaberman, lekma, loewis, petr.viktorin, pitrou |
| Date |
2021年08月02日.10:49:32 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1627901372.37.0.196918054921.issue15870@roundup.psfhosted.org> |
| In-reply-to |
| Content |
> 2. Use eval from C to create the class with a metaclass, eg.
> class Foo(metaclass=MessageMeta)
You can also call (PyObject_Call*) the metaclass with (name, bases, namespace); this should produce a class. Or not:
>>> class Foo(metaclass=print):
... def foo(self): pass
...
Foo () {'__module__': '__main__', '__qualname__': 'Foo', 'foo': <function Foo.foo at 0x7f6e9ddd9e50>}
PyType_FromSpecEx will surely need to limit the metaclass to subtypes of type. What other limitations are there? How closely can we approach the behavior of the `class` statement in Python?
> 3. Manually set FooType->ob_type = &MetaType
I wouldn't recommend doing that after PyType_Ready is called. Including indirectly, which the type-creation functions in the stable ABI do. |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2021年08月02日 10:49:32 | petr.viktorin | set | recipients:
+ petr.viktorin, loewis, jcea, amaury.forgeotdarc, belopolsky, pitrou, Arfrever, lekma, Alexander.Belopolsky, Robin.Schreiber, jhaberman |
| 2021年08月02日 10:49:32 | petr.viktorin | set | messageid: <1627901372.37.0.196918054921.issue15870@roundup.psfhosted.org> |
| 2021年08月02日 10:49:32 | petr.viktorin | link | issue15870 messages |
| 2021年08月02日 10:49:32 | petr.viktorin | create |
|