spacepaste

diff -r ce637db93b36 pypy/interpreter/function.py
a/pypy/interpreter/function.py [Mon Dec 03 17:42:13 2018 +0100]
b/pypy/interpreter/function.py [Mon Dec 03 22:12:07 2018 +0200]
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:
diff -r ce637db93b36 pypy/objspace/std/intobject.py
a/pypy/objspace/std/intobject.py [Mon Dec 03 17:42:13 2018 +0100]
b/pypy/objspace/std/intobject.py [Mon Dec 03 22:12:07 2018 +0200]
98 98 return w_obj
99 99
100 100 @unwrap_spec(length=int, byteorder='text', signed=bool)
101 def descr_to_bytes(self, space, length, byteorder, signed=False):
101 def descr_to_bytes(self, space, length, byteorder, __kwonly__, signed=False):
102 102 """to_bytes(...)
103 103 int.to_bytes(length, byteorder, *, signed=False) -> bytes
104 104
diff -r ce637db93b36 pypy/objspace/std/test/test_longobject.py
a/pypy/objspace/std/test/test_longobject.py [Mon Dec 03 17:42:13 2018 +0100]
b/pypy/objspace/std/test/test_longobject.py [Mon Dec 03 22:12:07 2018 +0200]
379 379 raises(OverflowError, (-5).to_bytes, 1, 'big')
380 380 raises(ValueError, (-5).to_bytes, 1, 'foo')
381 381 assert 65535 .to_bytes(length=2, byteorder='big') == b'\xff\xff'
382 raises(TypeError, 65535 .to_bytes, 2, 'big', False)
382 383
383 384 def test_negative_zero(self):
384 385 x = eval("-self._long(0)")