Skip to content

Commit

Permalink
oh make some stuff conditional
Browse files Browse the repository at this point in the history
  • Loading branch information
msullivan committed Dec 27, 2020
1 parent 94759b2 commit cbec4ee
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions mypyc/codegen/emitclass.py
Expand Up @@ -627,10 +627,10 @@ def generate_dealloc_for_class(cl: ClassIR,
emitter.emit_line('{}({} *self)'.format(dealloc_func_name, cl.struct_name(emitter.names)))
emitter.emit_line('{')
emitter.emit_line('PyObject_GC_UnTrack(self);')
emitter.emit_line('Py_TRASHCAN_BEGIN(self, {})'.format(dealloc_func_name))
emitter.emit_line('CPy_TRASHCAN_BEGIN(self, {})'.format(dealloc_func_name))
emitter.emit_line('{}(self);'.format(clear_func_name))
emitter.emit_line('Py_TYPE(self)->tp_free((PyObject *)self);')
emitter.emit_line('Py_TRASHCAN_END')
emitter.emit_line('CPy_TRASHCAN_END')
emitter.emit_line('}')


Expand Down
8 changes: 8 additions & 0 deletions mypyc/lib-rt/CPy.h
Expand Up @@ -453,6 +453,14 @@ void CPy_AddTraceback(const char *filename, const char *funcname, int line, PyOb

// Misc operations

#if PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION >= 8
#define CPy_TRASHCAN_BEGIN(op, dealloc) Py_TRASHCAN_BEGIN(op, dealloc)
#define CPy_TRASHCAN_END Py_TRASHCAN_END
#else
#define CPy_TRASHCAN_BEGIN(op, dealloc) Py_TRASHCAN_SAFE_BEGIN(op)
#define CPy_TRASHCAN_END Py_TRASHCAN_SAFE_END
#endif


// mypy lets ints silently coerce to floats, so a mypyc runtime float
// might be an int also
Expand Down

0 comments on commit cbec4ee

Please sign in to comment.