Skip to content

Instantly share code, notes, and snippets.

@natelust
natelust / Python Assignment Overloading Diff
Created June 20, 2019 19:57
A diff on python 3.7 that adds a __setself__ method to support assignment overloading
diff --git a/Include/object.h b/Include/object.h
index bcf78afe6b..5146e2050b 100644
--- a/Include/object.h
+++ b/Include/object.h
@@ -339,6 +339,7 @@ typedef int (*descrsetfunc) (PyObject *, PyObject *, PyObject *);
typedef int (*initproc)(PyObject *, PyObject *, PyObject *);
typedef PyObject *(*newfunc)(struct _typeobject *, PyObject *, PyObject *);
typedef PyObject *(*allocfunc)(struct _typeobject *, Py_ssize_t);
+typedef int (*setselffunc)(PyObject *, PyObject *);
@natelust
natelust / dummyClassFactory.py
Last active August 3, 2018 16:33
Python function to create a dummy classes from real classes
def _dummyFactory(cls):
"""Python function to wrap a class in a dummy implementation
Dummy classes created with this function will have all the
same methods and attributes of the class they wrap, but will
always evaluate to None. Attributes will be None in value,
methods will be callable, but they will always return None.
Parameters
----------