[issue47144] Allow setting __classcell__

2022-03-28 Thread Douglas Raillard
Douglas Raillard added the comment: EDIT: empty_list() is a class method of List, not ContainerBase -- ___ Python tracker ___ ___

[issue47144] Allow setting __classcell__

2022-03-28 Thread Douglas Raillard
Douglas Raillard added the comment: > Would bpo-47143 "Add functools.copy_class() which updates closures" solve > your use case? This looks like a similar issue indeed. If I'm able to copy a class "cleanly" (as defined in this other thread), that may solve the problem (hard to tell

[issue47144] Allow setting __classcell__

2022-03-28 Thread STINNER Victor
STINNER Victor added the comment: > This is unfortunate as there is a use-case for such trickery: if the method > of a class A are only used to be grafted onto another class B (monkey > patching), A.__classcell__ should be set to B so that super() works as > expected. Would you elaborate

[issue47144] Allow setting __classcell__

2022-03-28 Thread Douglas Raillard
New submission from Douglas Raillard : The cell object __classcell__ currently cannot be set by code invoked by metaclass.__new__. Attempts to do so will be caught by builtin___build_class__ in bltimodule.c: } else { const char *msg =