| 1596 | # klass is the class to instantiate, and k points to the topmost mark |
| 1597 | # object, following which are the arguments for klass.__init__. |
| 1598 | def _instantiate(self, klass, args): |
| 1599 | if (args or not isinstance(klass, type) or |
| 1600 | hasattr(klass, "__getinitargs__")): |
| 1601 | try: |
| 1602 | value = klass(*args) |
| 1603 | except TypeError as err: |
| 1604 | raise TypeError("in constructor for %s: %s" % |
| 1605 | (klass.__name__, str(err)), err.__traceback__) |
| 1606 | else: |
| 1607 | value = klass.__new__(klass) |
| 1608 | self.append(value) |
| 1609 | |
| 1610 | def load_inst(self): |
| 1611 | module = self.readline()[:-1].decode("ascii") |