|
47 | 47 | "__init__",
|
48 | 48 | "__metaclass__",
|
49 | 49 | "__module__",
|
| 50 | + "__name__", |
50 | 51 | "__new__",
|
51 | 52 | "__reduce__",
|
52 | 53 | "__reduce_ex__",
|
@@ -78,11 +79,11 @@ def fwd_request(stub, request_type, *args, **kwargs):
|
78 | 79 |
|
79 | 80 |
|
80 | 81 | class StubMetaClass(type):
|
81 |
| - def __repr__(self): |
82 |
| - if self.__module__: |
83 |
| - return "<stub class '%s.%s'>" % (self.__module__, self.__name__) |
| 82 | + def __repr__(cls): |
| 83 | + if cls.__module__: |
| 84 | + return "<stub class '%s.%s'>" % (cls.__module__, cls.__name__) |
84 | 85 | else:
|
85 |
| - return "<stub class '%s'>" % (self.__name__,) |
| 86 | + return "<stub class '%s'>" % (cls.__name__,) |
86 | 87 |
|
87 | 88 |
|
88 | 89 | def with_metaclass(meta, *bases):
|
@@ -131,9 +132,7 @@ def __del__(self):
|
131 | 132 |
|
132 | 133 | def __getattribute__(self, name):
|
133 | 134 | if name in LOCAL_ATTRS:
|
134 |
| - if name == "__class__": |
135 |
| - return None |
136 |
| - elif name == "__doc__": |
| 135 | + if name == "__doc__": |
137 | 136 | return self.__getattr__("__doc__")
|
138 | 137 | elif name in DELETED_ATTRS:
|
139 | 138 | raise AttributeError()
|
@@ -455,9 +454,14 @@ def _do_str(self):
|
455 | 454 | # it but not the case if we are not.
|
456 | 455 | class_dict["__slots__"].append("__weakref__")
|
457 | 456 |
|
| 457 | + class_module, class_name_only = class_name.rsplit(".", 1) |
458 | 458 | class_dict["___local_overrides___"] = overriden_attrs
|
| 459 | + class_dict["__module__"] = class_module |
459 | 460 | if parents:
|
460 |
| - return MetaExceptionWithConnection( |
| 461 | + to_return = MetaExceptionWithConnection( |
461 | 462 | class_name, (Stub, *parents), class_dict, connection
|
462 | 463 | )
|
463 |
| - return MetaWithConnection(class_name, (Stub,), class_dict, connection) |
| 464 | + else: |
| 465 | + to_return = MetaWithConnection(class_name, (Stub,), class_dict, connection) |
| 466 | + to_return.__name__ = class_name_only |
| 467 | + return to_return |
0 commit comments