summaryrefslogtreecommitdiff
path: root/main.py
diff options
context:
space:
mode:
Diffstat (limited to 'main.py')
-rw-r--r--main.py18
1 files changed, 10 insertions, 8 deletions
diff --git a/main.py b/main.py
index b4e5d77..85ad0cb 100644
--- a/main.py
+++ b/main.py
@@ -162,18 +162,20 @@ class YAML(object):
@property
def reader(self):
# type: () -> Any
- attr = '_' + sys._getframe().f_code.co_name
- if not hasattr(self, attr):
- setattr(self, attr, self.Reader(None, loader=self))
- return getattr(self, attr)
+ try:
+ return self._reader
+ except AttributeError:
+ self._reader = self.Reader(None, loader=self)
+ return self._reader
@property
def scanner(self):
# type: () -> Any
- attr = '_' + sys._getframe().f_code.co_name
- if not hasattr(self, attr):
- setattr(self, attr, self.Scanner(loader=self))
- return getattr(self, attr)
+ try:
+ return self._scanner
+ except:
+ self._scanner = self.Scanner(loader=self)
+ return self._scanner
@property
def parser(self):