From 1f2051414ac58454acd0e121527f5aa86f4de806 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Fri, 31 Oct 2014 14:49:15 -0400 Subject: don't use the class name as the key it's not necessarily unique --- mop/__init__.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/mop/__init__.py b/mop/__init__.py index 4d806d3..e8c95eb 100644 --- a/mop/__init__.py +++ b/mop/__init__.py @@ -20,11 +20,13 @@ def execute_method(method, invocant, args, kwargs): # necessary, but this allows us to pass python-level method calls through to # our mop infrastructure UNDERLYING_CLASSES = {} -def python_class_for(c): - name = c.slots["name"] - if name not in UNDERLYING_CLASSES.keys(): - UNDERLYING_CLASSES[name] = type(name, (object,), {}) - return UNDERLYING_CLASSES[name] +def python_class_for(c, name=None): + key = c.__hash__() + if key not in UNDERLYING_CLASSES.keys(): + if name is None: + name = c.get_name() + UNDERLYING_CLASSES[key] = type(name, (object,), {}) + return UNDERLYING_CLASSES[key] def python_install_method(c, name, method): setattr( @@ -36,7 +38,7 @@ def python_install_method(c, name, method): # and finally, bootstrap helpers to create hardcoded structures during the # bootstrap (which we will inflate into real structures at the end) def bootstrap_create_class(name, superclass): - return BasicInstance( + c = BasicInstance( globals().get("Class"), { "name": name, @@ -45,6 +47,8 @@ def bootstrap_create_class(name, superclass): "attributes": {}, }, ) + python_class_for(c, name) + return c def bootstrap_create_method(name, body): return BasicInstance( -- cgit v1.2.3-54-g00ecf