| 639 | raise BoxTypeError(str(err)) from _exception_cause(err) |
| 640 | |
| 641 | def __getattr__(self, item): |
| 642 | try: |
| 643 | try: |
| 644 | value = self.__getitem__(item, _ignore_default=True) |
| 645 | except KeyError: |
| 646 | value = object.__getattribute__(self, item) |
| 647 | except AttributeError as err: |
| 648 | if item == "__getstate__": |
| 649 | raise BoxKeyError(item) from _exception_cause(err) |
| 650 | if item == "_box_config": |
| 651 | raise BoxError("_box_config key must exist") from _exception_cause(err) |
| 652 | if self._box_config["conversion_box"]: |
| 653 | safe_key = self._safe_attr(item) |
| 654 | if safe_key in self._box_config["__safe_keys"]: |
| 655 | return self.__getitem__(self._box_config["__safe_keys"][safe_key]) |
| 656 | if self._box_config["default_box"]: |
| 657 | if item.startswith("_") and item.endswith("_"): |
| 658 | raise BoxKeyError(f"{item}: Does not exist and internal methods are never defaulted") |
| 659 | return self.__get_default(item, attr=True) |
| 660 | raise BoxKeyError(str(err)) from _exception_cause(err) |
| 661 | return value |
| 662 | |
| 663 | def __setitem__(self, key, value): |
| 664 | if key != "_box_config" and self._box_config["frozen_box"] and self._box_config["__created"]: |