Skip to content

Commit

Permalink
Opt out from the managed dict for compiled classes on Python 3.11 (#1…
Browse files Browse the repository at this point in the history
…3830)

This fixes the last failing test on Python 3.11
  • Loading branch information
ilevkivskyi authored Oct 8, 2022
1 parent 589ad1c commit 1a8e6c8
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions mypyc/lib-rt/misc_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// These are registered in mypyc.primitives.misc_ops.

#include <Python.h>
#include <patchlevel.h>
#include "CPy.h"

PyObject *CPy_GetCoro(PyObject *obj)
Expand Down Expand Up @@ -285,6 +286,11 @@ PyObject *CPyType_FromTemplate(PyObject *template,

Py_XDECREF(dummy_class);

#if PY_MINOR_VERSION == 11
// This is a hack. Python 3.11 doesn't include good public APIs to work with managed
// dicts, which are the default for heap types. So we try to opt-out until Python 3.12.
t->ht_type.tp_flags &= ~Py_TPFLAGS_MANAGED_DICT;
#endif
return (PyObject *)t;

error:
Expand Down

0 comments on commit 1a8e6c8

Please sign in to comment.