39 |
39 |
'qualname?', |
40 |
40 |
'w_kw_defs?'] |
41 |
41 |
|
42 |
|
w_kw_defs = None |
43 |
|
|
44 |
42 |
def __init__(self, space, code, w_globals=None, defs_w=[], kw_defs_w=None, |
45 |
43 |
closure=None, w_ann=None, forcename=None, qualname=None): |
46 |
44 |
self.space = space |
… |
54 |
52 |
self.w_func_dict = None # filled out below if needed |
55 |
53 |
self.w_module = None |
56 |
54 |
self.w_ann = w_ann |
|
55 |
self.w_kw_defs = None |
57 |
56 |
# |
58 |
57 |
if kw_defs_w is not None: |
59 |
58 |
self.init_kwdefaults_dict(kw_defs_w) |
… |
406 |
405 |
def init_kwdefaults_dict(self, kw_defs_w): |
407 |
406 |
# use the moduledict logic to get normally-constant entries |
408 |
407 |
space = self.space |
409 |
|
w_dict = space.newdict(module=True) |
410 |
|
for w_name, w_value in kw_defs_w: |
411 |
|
space.setitem(w_dict, w_name, w_value) |
412 |
|
self.w_kw_defs = w_dict |
|
408 |
if hasattr(space, 'w_dict'): # normal path |
|
409 |
w_dict = space.newdict(module=True) |
|
410 |
for w_name, w_value in kw_defs_w: |
|
411 |
space.setitem(w_dict, w_name, w_value) |
|
412 |
self.w_kw_defs = w_dict |
|
413 |
else: |
|
414 |
del self.w_kw_defs # delayed path during initialization |
|
415 |
self._saved_kw_defs_w = kw_defs_w |
|
416 |
|
|
417 |
def __getattr__(self, attr): |
|
418 |
if attr == 'w_kw_defs' and hasattr(self, '_saved_kw_defs_w'): |
|
419 |
assert hasattr(self.space, 'w_dict') |
|
420 |
self.init_kwdefaults_dict(self._saved_kw_defs_w) |
|
421 |
del self._saved_kw_defs_w |
|
422 |
return self.w_kw_defs |
|
423 |
raise AttributeError |
413 |
424 |
|
414 |
425 |
def fget_func_doc(self, space): |
415 |
426 |
if self.w_doc is None: |