[pypy-commit] pypy py3k: hg merge default
arigo
pypy.commits at gmail.com
Wed Aug 31 04:41:04 EDT 2016
Author: Armin Rigo <arigo at tunes.org>
Branch: py3k
Changeset: r86766:c080e77ee085
Date: 2016-08-31 10:40 +0200
http://bitbucket.org/pypy/pypy/changeset/c080e77ee085/
Log: hg merge default
diff --git a/lib-python/2.7/distutils/sysconfig_pypy.py b/lib-python/2.7/distutils/sysconfig_pypy.py
--- a/lib-python/2.7/distutils/sysconfig_pypy.py
+++ b/lib-python/2.7/distutils/sysconfig_pypy.py
@@ -122,22 +122,24 @@
"""Dummy method to let some easy_install packages that have
optional C speedup components.
"""
+ def customize(executable, flags):
+ command = compiler.executables[executable] + flags
+ setattr(compiler, executable, command)
+
if compiler.compiler_type == "unix":
compiler.compiler_so.extend(['-O2', '-fPIC', '-Wimplicit'])
compiler.shared_lib_extension = get_config_var('SO')
if "CPPFLAGS" in os.environ:
cppflags = shlex.split(os.environ["CPPFLAGS"])
- compiler.compiler.extend(cppflags)
- compiler.compiler_so.extend(cppflags)
- compiler.linker_so.extend(cppflags)
+ for executable in ('compiler', 'compiler_so', 'linker_so'):
+ customize(executable, cppflags)
if "CFLAGS" in os.environ:
cflags = shlex.split(os.environ["CFLAGS"])
- compiler.compiler.extend(cflags)
- compiler.compiler_so.extend(cflags)
- compiler.linker_so.extend(cflags)
+ for executable in ('compiler', 'compiler_so', 'linker_so'):
+ customize(executable, cflags)
if "LDFLAGS" in os.environ:
ldflags = shlex.split(os.environ["LDFLAGS"])
- compiler.linker_so.extend(ldflags)
+ customize('linker_so', ldflags)
from sysconfig_cpython import (
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/pypy/objspace/std/newformat.py b/pypy/objspace/std/newformat.py
--- a/pypy/objspace/std/newformat.py
+++ b/pypy/objspace/std/newformat.py
@@ -8,6 +8,7 @@
from rpython.rlib.objectmodel import specialize
from rpython.rlib.rfloat import copysign, formatd
from rpython.rlib.rarithmetic import r_uint, intmask
+from pypy.interpreter.signature import Signature
@specialize.argtype(1)
@@ -40,15 +41,18 @@
ANS_MANUAL = 3
-def make_template_formatting_class():
+format_signature = Signature([], 'args', 'kwargs')
+
+
+def make_template_formatting_class(for_unicode):
class TemplateFormatter(object):
+ is_unicode = for_unicode
parser_list_w = None
- def __init__(self, space, is_unicode, template):
+ def __init__(self, space, template):
self.space = space
- self.is_unicode = is_unicode
- self.empty = u"" if is_unicode else ""
+ self.empty = u"" if self.is_unicode else ""
self.template = template
def build(self, args, w_kwargs):
@@ -198,14 +202,10 @@
if index == -1:
kwarg = name[:i]
if self.is_unicode:
- try:
- arg_key = kwarg.encode("latin-1")
- except UnicodeEncodeError:
- # Not going to be found in a dict of strings.
- raise OperationError(space.w_KeyError, space.wrap(kwarg))
+ w_kwarg = space.newunicode(kwarg)
else:
- arg_key = kwarg
- w_arg = space.getitem(self.w_kwargs, space.wrap(arg_key))
+ w_kwarg = space.newbytes(kwarg)
+ w_arg = space.getitem(self.w_kwargs, w_kwarg)
else:
if self.args is None:
w_msg = space.wrap("Format string contains positional "
@@ -356,14 +356,8 @@
return space.iter(space.newlist(self.parser_list_w))
return TemplateFormatter
-StrTemplateFormatter = make_template_formatting_class()
-UnicodeTemplateFormatter = make_template_formatting_class()
-
-def str_template_formatter(space, template):
- return StrTemplateFormatter(space, False, template)
-
-def unicode_template_formatter(space, template):
- return UnicodeTemplateFormatter(space, True, template)
+str_template_formatter = make_template_formatting_class(for_unicode=False)
+unicode_template_formatter = make_template_formatting_class(for_unicode=True)
def format_method(space, w_string, args, w_kwargs, is_unicode):
@@ -400,16 +394,16 @@
LONG_DIGITS = string.digits + string.ascii_lowercase
-def make_formatting_class():
+def make_formatting_class(for_unicode):
class Formatter(BaseFormatter):
"""__format__ implementation for builtin types."""
+ is_unicode = for_unicode
_grouped_digits = None
- def __init__(self, space, is_unicode, spec):
+ def __init__(self, space, spec):
self.space = space
- self.is_unicode = is_unicode
- self.empty = u"" if is_unicode else ""
+ self.empty = u"" if self.is_unicode else ""
self.spec = spec
def _is_alignment(self, c):
@@ -1146,12 +1140,9 @@
self._unknown_presentation("complex")
return Formatter
-StrFormatter = make_formatting_class()
+unicode_formatter = make_formatting_class(for_unicode=True)
-def unicode_formatter(space, spec):
- return StrFormatter(space, True, spec)
-
@specialize.arg(2)
def run_formatter(space, w_format_spec, meth, *args):
formatter = unicode_formatter(space, space.unicode_w(w_format_spec))
diff --git a/pypy/objspace/std/objspace.py b/pypy/objspace/std/objspace.py
--- a/pypy/objspace/std/objspace.py
+++ b/pypy/objspace/std/objspace.py
@@ -157,6 +157,7 @@
# poor man's x.decode('ascii', 'replace'), since it's not
# supported by RPython
if not we_are_translated():
+ import pdb;pdb.set_trace()
print 'WARNING: space.wrap() called on a non-ascii byte string: %r' % x
lst = []
for ch in x:
diff --git a/pypy/objspace/std/test/test_newformat.py b/pypy/objspace/std/test/test_newformat.py
--- a/pypy/objspace/std/test/test_newformat.py
+++ b/pypy/objspace/std/test/test_newformat.py
@@ -216,7 +216,9 @@
assert self.s("{!r}").format(x()) == "32"
def test_non_latin1_key(self):
- raises(KeyError, self.s("{\u1000}").format)
+ raises(KeyError, u"{\u1000}".format)
+ d = {u"\u1000": u"foo"}
+ assert u"{\u1000}".format(**d) == u"foo"
class AppTestBoolFormat:
diff --git a/pypy/objspace/std/unicodeobject.py b/pypy/objspace/std/unicodeobject.py
--- a/pypy/objspace/std/unicodeobject.py
+++ b/pypy/objspace/std/unicodeobject.py
@@ -379,7 +379,11 @@
w_kwds = space.newdict()
if __args__.keywords:
for i in range(len(__args__.keywords)):
- space.setitem(w_kwds, space.wrap(__args__.keywords[i]),
+ try: # pff
+ arg = __args__.keywords[i].decode('utf-8')
+ except UnicodeDecodeError:
+ continue # uh, just skip that
+ space.setitem(w_kwds, space.newunicode(arg),
__args__.keywords_w[i])
return newformat.format_method(space, self, __args__.arguments_w,
w_kwds, True)
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