[pypy-commit] pypy py3k: hg merge default
rlamy
pypy.commits at gmail.com
Tue Aug 30 14:02:27 EDT 2016
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: py3k
Changeset: r86750:2498fb9ffc58
Date: 2016-08-30 19:01 +0100
http://bitbucket.org/pypy/pypy/changeset/2498fb9ffc58/
Log: hg merge default
diff --git a/pypy/module/__builtin__/descriptor.py b/pypy/module/__builtin__/descriptor.py
--- a/pypy/module/__builtin__/descriptor.py
+++ b/pypy/module/__builtin__/descriptor.py
@@ -27,6 +27,14 @@
self.w_objtype = w_type
self.w_self = w_obj_or_type
+ def descr_repr(self, space):
+ if self.w_objtype is not None:
+ objtype_name = "<%s object>" % self.w_objtype.getname(space)
+ else:
+ objtype_name = 'NULL'
+ return space.wrap("<super: <class '%s'>, %s>" % (
+ self.w_starttype.getname(space), objtype_name))
+
def get(self, space, w_obj, w_type=None):
if self.w_self is None or space.is_w(w_obj, space.w_None):
return self
@@ -114,7 +122,10 @@
'super',
__new__ = generic_new_descr(W_Super),
__init__ = interp2app(W_Super.descr_init),
+ __repr__ = interp2app(W_Super.descr_repr),
__thisclass__ = interp_attrproperty_w("w_starttype", W_Super),
+ __self__ = interp_attrproperty_w("w_self", W_Super),
+ __self_class__ = interp_attrproperty_w("w_objtype", W_Super),
__getattribute__ = interp2app(W_Super.getattribute),
__get__ = interp2app(W_Super.get),
__doc__ = """\
diff --git a/pypy/module/__builtin__/test/test_descriptor.py b/pypy/module/__builtin__/test/test_descriptor.py
--- a/pypy/module/__builtin__/test/test_descriptor.py
+++ b/pypy/module/__builtin__/test/test_descriptor.py
@@ -303,6 +303,24 @@
assert super(B, B()).__thisclass__ is B
assert super(A, B()).__thisclass__ is A
+ def test_super_self_selfclass(self):
+ class A(object):
+ pass
+ class B(A):
+ pass
+ b = B()
+ assert super(A, b).__self__ is b
+ assert super(A).__self__ is None
+ assert super(A, b).__self_class__ is B
+ assert super(A).__self_class__ is None
+
+ def test_super_repr(self):
+ class A(object):
+ def __repr__(self):
+ return super(A, self).__repr__() + '!'
+ assert repr(A()).endswith('>!')
+ assert repr(super(A, A())) == "<super: <class 'A'>, <A object>>"
+
def test_property_docstring(self):
assert property.__doc__.startswith('property')
diff --git a/rpython/rlib/rsocket.py b/rpython/rlib/rsocket.py
--- a/rpython/rlib/rsocket.py
+++ b/rpython/rlib/rsocket.py
@@ -526,7 +526,7 @@
fd=_c.INVALID_SOCKET, inheritable=True):
"""Create a new socket."""
if _c.invalid_socket(fd):
- if not inheritable and SOCK_CLOEXEC is not None:
+ if not inheritable and 'SOCK_CLOEXEC' in constants:
# Non-inheritable: we try to call socket() with
# SOCK_CLOEXEC, which may fail. If we get EINVAL,
# then we fall back to the SOCK_CLOEXEC-less case.
@@ -655,7 +655,7 @@
address, addr_p, addrlen_p = self._addrbuf()
try:
remove_inheritable = not inheritable
- if (not inheritable and SOCK_CLOEXEC is not None
+ if (not inheritable and 'SOCK_CLOEXEC' in constants
and _c.HAVE_ACCEPT4
and _accept4_syscall.attempt_syscall()):
newfd = _c.socketaccept4(self.fd, addr_p, addrlen_p,
@@ -1138,7 +1138,7 @@
try:
res = -1
remove_inheritable = not inheritable
- if not inheritable and SOCK_CLOEXEC is not None:
+ if not inheritable and 'SOCK_CLOEXEC' in constants:
# Non-inheritable: we try to call socketpair() with
# SOCK_CLOEXEC, which may fail. If we get EINVAL,
# then we fall back to the SOCK_CLOEXEC-less case.
More information about the pypy-commit
mailing list