[pypy-commit] cffi sirtom67/float_complex: unskip the complex test in c/test_c.py. It still doesn't pass but gets past a couple points
Author: Tom KraussBranch: sirtom67/float_complex Changeset: r2865:d3cb148ff6fa Date: 2017-01-22 19:36 -0600 http://bitbucket.org/cffi/cffi/changeset/d3cb148ff6fa/ Log:unskip the complex test in c/test_c.py. It still doesn't pass but gets past a couple points diff --git a/c/_cffi_backend.c b/c/_cffi_backend.c --- a/c/_cffi_backend.c +++ b/c/_cffi_backend.c @@ -899,6 +899,25 @@ _write_raw_data(long double); } +#define _write_raw_complex_data(type) \ +do { \ +if (size == 2*sizeof(type)) { \ +type r = (type)source.real;\ +memcpy(target, , sizeof(type)); \ +type i = (type)source.imag;\ +memcpy(target+sizeof(type), , sizeof(type)); \ +return;\ +} \ +} while(0) + +static void +write_raw_complex_data(char *target, Py_complex source, int size) +{ +_write_raw_complex_data(float); +_write_raw_complex_data(double); +Py_FatalError("write_raw_complex_data: bad float size"); +} + static PyObject * new_simple_cdata(char *data, CTypeDescrObject *ct) { @@ -3574,6 +3593,40 @@ } return (PyObject *)cd; } + + +else if (ct->ct_flags & CT_PRIMITIVE_COMPLEX) { +/* cast to a complex */ +Py_complex value; +PyObject *io; +printf("_cffi_backend.c do_cast ct->ct_size=%ld\n", ct->ct_size); +if (CData_Check(ob)) { +CDataObject *cdsrc = (CDataObject *)ob; + +if (!(cdsrc->c_type->ct_flags & CT_PRIMITIVE_ANY)) +goto cannot_cast; +io = convert_to_object(cdsrc->c_data, cdsrc->c_type); +if (io == NULL) +return NULL; +} +else { +io = ob; +Py_INCREF(io); +} + +value = PyComplex_AsCComplex(io); +Py_DECREF(io); +if (value.real == -1.0 && value.imag == 0.0 && PyErr_Occurred()) +return NULL; + +cd = _new_casted_primitive(ct); +if (cd != NULL) { +write_raw_complex_data(cd->c_data, value, ct->ct_size); +} +return (PyObject *)cd; +} + + else { PyErr_Format(PyExc_TypeError, "cannot cast to ctype '%s'", ct->ct_name); diff --git a/c/test_c.py b/c/test_c.py --- a/c/test_c.py +++ b/c/test_c.py @@ -183,10 +183,9 @@ py.test.raises(TypeError, cast, p, None) def test_complex_types(): -py.test.skip("later") INF = 1E200 * 1E200 -for name in ["float", "double"]: -p = new_primitive_type("_Complex " + name) +for name in ["float"]: #, "double"]: +p = new_primitive_type(name + " _Complex") assert bool(cast(p, 0)) assert bool(cast(p, INF)) assert bool(cast(p, -INF)) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.5: Implement PyObject_Bytes
Author: Ronan LamyBranch: py3.5 Changeset: r89702:742da0d33a6a Date: 2017-01-23 00:03 + http://bitbucket.org/pypy/pypy/changeset/742da0d33a6a/ Log:Implement PyObject_Bytes diff --git a/pypy/module/cpyext/object.py b/pypy/module/cpyext/object.py --- a/pypy/module/cpyext/object.py +++ b/pypy/module/cpyext/object.py @@ -1,7 +1,7 @@ from rpython.rtyper.lltypesystem import rffi, lltype from pypy.module.cpyext.api import ( cpython_api, generic_cpy_call, CANNOT_FAIL, Py_ssize_t, Py_ssize_tP, -PyVarObject, Py_buffer, size_t, slot_function, +PyVarObject, Py_buffer, size_t, slot_function, api_decl, cts, PyBUF_FORMAT, PyBUF_ND, PyBUF_STRIDES, Py_TPFLAGS_HEAPTYPE, Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT, Py_GE, CONST_STRING, CONST_STRINGP, FILEP, fwrite) @@ -11,6 +11,7 @@ from pypy.module.cpyext.typeobject import PyTypeObjectPtr from pypy.module.cpyext.pyerrors import PyErr_NoMemory, PyErr_BadInternalCall from pypy.objspace.std.typeobject import W_TypeObject +from pypy.objspace.std.bytesobject import invoke_bytes_method from pypy.interpreter.error import OperationError, oefmt import pypy.module.__builtin__.operation as operation @@ -247,6 +248,19 @@ return space.wrap("") return space.str(w_obj) +@api_decl("PyObject * PyObject_Bytes(PyObject *v)", cts) +def PyObject_Bytes(space, w_obj): +if w_obj is None: +return space.newbytes("") +if space.type(w_obj) is space.w_bytes: +return w_obj +w_result = invoke_bytes_method(space, w_obj) +if w_result is not None: +return w_result +# return PyBytes_FromObject(space, w_obj) +buffer = space.buffer_w(w_obj, space.BUF_FULL_RO) +return space.newbytes(buffer.as_str()) + @cpython_api([PyObject], PyObject) def PyObject_Repr(space, w_obj): """Compute a string representation of object o. Returns the string diff --git a/pypy/module/cpyext/test/test_object.py b/pypy/module/cpyext/test/test_object.py --- a/pypy/module/cpyext/test/test_object.py +++ b/pypy/module/cpyext/test/test_object.py @@ -296,6 +296,20 @@ a = module.empty_format('hello') assert isinstance(a, str) +def test_Bytes(self): +class sub1(bytes): +pass +class sub2(bytes): +def __bytes__(self): +return self +module = self.import_extension('test_Bytes', [ +('asbytes', 'METH_O', + """ +return PyObject_Bytes(args); + """)]) +assert type(module.asbytes(sub1(b''))) is bytes +assert type(module.asbytes(sub2(b''))) is sub2 + class AppTestPyBuffer_FillInfo(AppTestCpythonExtensionBase): """ PyBuffer_FillInfo populates the fields of a Py_buffer from its arguments. ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.5-fstring-pep498: more tests
Author: Armin RigoBranch: py3.5-fstring-pep498 Changeset: r89701:75a8124d1219 Date: 2017-01-23 00:07 +0100 http://bitbucket.org/pypy/pypy/changeset/75a8124d1219/ Log:more tests diff --git a/pypy/interpreter/astcompiler/test/test_compiler.py b/pypy/interpreter/astcompiler/test/test_compiler.py --- a/pypy/interpreter/astcompiler/test/test_compiler.py +++ b/pypy/interpreter/astcompiler/test/test_compiler.py @@ -1168,6 +1168,8 @@ yield self.st, """z = f'}}'""", 'z', '}' yield self.st, """z = f'x{{y'""", 'z', 'x{y' yield self.st, """z = f'x}}y'""", 'z', 'x}y' +yield self.st, """z = f'{{{4*10}}}'""", 'z', '{40}' +yield self.st, r"""z = fr'x={4*10}\n'""", 'z', 'x=40\\n' yield self.st, """x = 'hi'; z = f'{x}'""", 'z', 'hi' yield self.st, """x = 'hi'; z = f'{x!s}'""", 'z', 'hi' ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.5-fstring-pep498: {...:format_spec}
Author: Armin RigoBranch: py3.5-fstring-pep498 Changeset: r89700:7b27b30dddca Date: 2017-01-22 23:58 +0100 http://bitbucket.org/pypy/pypy/changeset/7b27b30dddca/ Log:{...:format_spec} diff --git a/pypy/interpreter/astcompiler/assemble.py b/pypy/interpreter/astcompiler/assemble.py --- a/pypy/interpreter/astcompiler/assemble.py +++ b/pypy/interpreter/astcompiler/assemble.py @@ -759,7 +759,8 @@ return -_num_args(arg) - 1 def _compute_FORMAT_VALUE(arg): -#if arg contains some flag: return -1 +if (arg & consts.FVS_MASK) == consts.FVS_HAVE_SPEC: +return -1 return 0 def _compute_BUILD_STRING(arg): diff --git a/pypy/interpreter/astcompiler/astbuilder.py b/pypy/interpreter/astcompiler/astbuilder.py --- a/pypy/interpreter/astcompiler/astbuilder.py +++ b/pypy/interpreter/astcompiler/astbuilder.py @@ -1238,7 +1238,7 @@ parse_tree = self.recursive_parser.parse_source(source, info) return ast_from_node(self.space, parse_tree, info) -def _f_string_expr(self, joined_pieces, u, start, atom_node): +def _f_string_expr(self, joined_pieces, u, start, atom_node, rec=0): conversion = -1 # the conversion char. -1 if not specified. format_spec = None nested_depth = 0# nesting level for braces/parens/brackets in exprs @@ -1270,7 +1270,14 @@ self.error("f-string: invalid conversion character: " "expected 's', 'r', or 'a'", atom_node) if ch == u':': -XXX +if rec >= 2: +self.error("f-string: expressions nested too deeply", atom_node) +subpieces = [] +p = self._parse_f_string(subpieces, u, p, atom_node, rec + 1) +format_spec = self._f_string_to_ast_node(subpieces, atom_node) +ch = u[p] if p >= 0 else u'\x00' +p += 1 + if ch != u'}': self.error("f-string: expecting '}'", atom_node) end_f_string = p @@ -1283,36 +1290,50 @@ joined_pieces.append(fval) return end_f_string -def _parse_f_string(self, joined_pieces, w_string, atom_node): +def _parse_f_string(self, joined_pieces, u, start, atom_node, rec=0): space = self.space -u = space.unicode_w(w_string) -start = 0 -p1 = u.find(u'{') +p1 = u.find(u'{', start) +prestart = start while True: if p1 < 0: p1 = len(u) p2 = u.find(u'}', start, p1) if p2 >= 0: +self._f_constant_string(joined_pieces, u[prestart:p2], +atom_node) pn = p2 + 1 if pn < len(u) and u[pn] == u'}':# '}}' => single '}' -self._f_constant_string(joined_pieces, u[start:pn], -atom_node) start = pn + 1 -else: -self.error("f-string: single '}' is not allowed", atom_node) -continue -self._f_constant_string(joined_pieces, u[start:p1], atom_node) +prestart = pn +continue +return p2 # found a single '}', stop here +self._f_constant_string(joined_pieces, u[prestart:p1], atom_node) if p1 == len(u): -break # no more '{' or '}' left +return -1 # no more '{' or '}' left pn = p1 + 1 if pn < len(u) and u[pn] == u'{':# '{{' => single '{' -start = pn -p1 = u.find(u'{', start + 1) +start = pn + 1 +prestart = pn else: assert u[p1] == u'{' -start = self._f_string_expr(joined_pieces, u, pn, atom_node) +start = self._f_string_expr(joined_pieces, u, pn, +atom_node, rec) assert u[start - 1] == u'}' -p1 = u.find(u'{', start) +prestart = start +p1 = u.find(u'{', start) + +def _f_string_to_ast_node(self, joined_pieces, atom_node): +# remove empty Strs +values = [node for node in joined_pieces + if not (isinstance(node, ast.Str) and not node.s)] +if len(values) > 1: +return ast.JoinedStr(values, atom_node.get_lineno(), + atom_node.get_column()) +elif len(values) == 1: +return values[0] +else: +assert len(joined_pieces) > 0# they are all empty strings +return joined_pieces[0] def handle_atom(self, atom_node): first_child = atom_node.get_child(0) @@ -1349,7 +1370,12 @@ if not saw_f: self._add_constant_string(joined_pieces, w_next, atom_node) else: -
[pypy-commit] pypy py3.5-fstring-pep498: better error checking; and found a more reasonable way to forbid comments than CPython uses
Author: Armin RigoBranch: py3.5-fstring-pep498 Changeset: r89699:3cc879e93827 Date: 2017-01-22 23:30 +0100 http://bitbucket.org/pypy/pypy/changeset/3cc879e93827/ Log:better error checking; and found a more reasonable way to forbid comments than CPython uses diff --git a/pypy/interpreter/astcompiler/astbuilder.py b/pypy/interpreter/astcompiler/astbuilder.py --- a/pypy/interpreter/astcompiler/astbuilder.py +++ b/pypy/interpreter/astcompiler/astbuilder.py @@ -1218,14 +1218,22 @@ # or even tokenized together with the rest of the source code! from pypy.interpreter.pyparser import pyparse +# complain if 'source' is only whitespace or an empty string +for c in source: +if c not in ' \t\n\r\v\f': +break +else: +self.error("f-string: empty expression not allowed", atom_node) + if self.recursive_parser is None: self.error("internal error: parser not available for parsing " "the expressions inside the f-string", atom_node) -source = source.encode('utf-8') +source = '(%s)' % source.encode('utf-8') info = pyparse.CompileInfo("", "eval", consts.PyCF_SOURCE_IS_UTF8 | - consts.PyCF_IGNORE_COOKIE, + consts.PyCF_IGNORE_COOKIE | + consts.PyCF_REFUSE_COMMENTS, optimize=self.compile_info.optimize) parse_tree = self.recursive_parser.parse_source(source, info) return ast_from_node(self.space, parse_tree, info) @@ -1247,7 +1255,6 @@ if ch == u'!' and p < len(u) and u[p] == u'=': continue break # normal way out of this loop -# XXX forbid comment, but how? else: ch = u'\x00' # diff --git a/pypy/interpreter/astcompiler/consts.py b/pypy/interpreter/astcompiler/consts.py --- a/pypy/interpreter/astcompiler/consts.py +++ b/pypy/interpreter/astcompiler/consts.py @@ -33,6 +33,7 @@ PyCF_IGNORE_COOKIE = 0x0800 PyCF_ACCEPT_NULL_BYTES = 0x1000 # PyPy only, for compile() PyCF_FOUND_ENCODING = 0x2000 # PyPy only, for pytokenizer +PyCF_REFUSE_COMMENTS = 0x4000 # PyPy only, for f-strings # Masks and values used by FORMAT_VALUE opcode FVC_MASK = 0x3 diff --git a/pypy/interpreter/astcompiler/test/test_compiler.py b/pypy/interpreter/astcompiler/test/test_compiler.py --- a/pypy/interpreter/astcompiler/test/test_compiler.py +++ b/pypy/interpreter/astcompiler/test/test_compiler.py @@ -1174,6 +1174,15 @@ yield self.st, """x = 'hi'; z = f'{x!r}'""", 'z', "'hi'" yield self.st, """x = 'hi'; z = f'{x!a}'""", 'z', "'hi'" +yield self.st, """x = 'hi'; z = f'''{\nx}'''""", 'z', 'hi' + +def test_fstring_error(self): +raises(SyntaxError, self.run, "f'{}'") +raises(SyntaxError, self.run, "f'{ \t }'") +raises(SyntaxError, self.run, "f'{5#}'") +raises(SyntaxError, self.run, "f'{5)#}'") +raises(SyntaxError, self.run, "f'''{5)\n#}'''") + class AppTestCompiler: diff --git a/pypy/interpreter/pyparser/pytokenizer.py b/pypy/interpreter/pyparser/pytokenizer.py --- a/pypy/interpreter/pyparser/pytokenizer.py +++ b/pypy/interpreter/pyparser/pytokenizer.py @@ -187,6 +187,9 @@ continue if line[pos] == '#': # skip full-line comment, but still check that it is valid utf-8 +if flags & consts.PyCF_REFUSE_COMMENTS: +raise TokenError("comments not allowed here", + line, lnum, pos, token_list) if not verify_utf8(line): raise bad_utf8("comment", line, lnum, pos, token_list, flags) @@ -257,6 +260,9 @@ last_comment = '' elif initial == '#': # skip comment, but still check that it is valid utf-8 +if flags & consts.PyCF_REFUSE_COMMENTS: +raise TokenError("comments not allowed here", + line, lnum, start, token_list) if not verify_utf8(token): raise bad_utf8("comment", line, lnum, start, token_list, flags) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.5-fstring-pep498: conversions (!s, !r, !a)
Author: Armin RigoBranch: py3.5-fstring-pep498 Changeset: r89698:19d22e69d149 Date: 2017-01-22 23:07 +0100 http://bitbucket.org/pypy/pypy/changeset/19d22e69d149/ Log:conversions (!s, !r, !a) diff --git a/pypy/interpreter/astcompiler/astbuilder.py b/pypy/interpreter/astcompiler/astbuilder.py --- a/pypy/interpreter/astcompiler/astbuilder.py +++ b/pypy/interpreter/astcompiler/astbuilder.py @@ -1249,18 +1249,26 @@ break # normal way out of this loop # XXX forbid comment, but how? else: -raise self.error("f-string: unterminated '{' expression") +ch = u'\x00' +# if nested_depth > 0: -self.error("f-string: mismatched '(', '{' or '['") +self.error("f-string: mismatched '(', '{' or '['", atom_node) +end_expression = p - 1 if ch == u'!': -XXX +if p + 1 < len(u): +conversion = ord(u[p]) +ch = u[p + 1] +p += 2 +if conversion not in (ord('s'), ord('r'), ord('a')): +self.error("f-string: invalid conversion character: " + "expected 's', 'r', or 'a'", atom_node) if ch == u':': XXX -assert ch == u'}' +if ch != u'}': +self.error("f-string: expecting '}'", atom_node) end_f_string = p -p -= 1 # drop the final '}' -assert p >= start -expr = self._f_string_compile(u[start:p], atom_node) +assert end_expression >= start +expr = self._f_string_compile(u[start:end_expression], atom_node) assert isinstance(expr, ast.Expression) fval = ast.FormattedValue(expr.body, conversion, format_spec, atom_node.get_lineno(), @@ -1284,7 +1292,7 @@ atom_node) start = pn + 1 else: -self.error("f-string: unexpected '}'", atom_node) +self.error("f-string: single '}' is not allowed", atom_node) continue self._f_constant_string(joined_pieces, u[start:p1], atom_node) if p1 == len(u): diff --git a/pypy/interpreter/astcompiler/codegen.py b/pypy/interpreter/astcompiler/codegen.py --- a/pypy/interpreter/astcompiler/codegen.py +++ b/pypy/interpreter/astcompiler/codegen.py @@ -1499,7 +1499,11 @@ def visit_FormattedValue(self, fmt): fmt.value.walkabout(self) -self.emit_op_arg(ops.FORMAT_VALUE, 0) +arg = 0 +if fmt.conversion == ord('s'): arg = consts.FVC_STR +if fmt.conversion == ord('r'): arg = consts.FVC_REPR +if fmt.conversion == ord('a'): arg = consts.FVC_ASCII +self.emit_op_arg(ops.FORMAT_VALUE, arg) class TopLevelCodeGenerator(PythonCodeGenerator): diff --git a/pypy/interpreter/astcompiler/consts.py b/pypy/interpreter/astcompiler/consts.py --- a/pypy/interpreter/astcompiler/consts.py +++ b/pypy/interpreter/astcompiler/consts.py @@ -33,3 +33,12 @@ PyCF_IGNORE_COOKIE = 0x0800 PyCF_ACCEPT_NULL_BYTES = 0x1000 # PyPy only, for compile() PyCF_FOUND_ENCODING = 0x2000 # PyPy only, for pytokenizer + +# Masks and values used by FORMAT_VALUE opcode +FVC_MASK = 0x3 +FVC_NONE = 0x0 +FVC_STR = 0x1 +FVC_REPR = 0x2 +FVC_ASCII = 0x3 +FVS_MASK = 0x4 +FVS_HAVE_SPEC = 0x4 diff --git a/pypy/interpreter/astcompiler/test/test_compiler.py b/pypy/interpreter/astcompiler/test/test_compiler.py --- a/pypy/interpreter/astcompiler/test/test_compiler.py +++ b/pypy/interpreter/astcompiler/test/test_compiler.py @@ -1164,6 +1164,15 @@ def test_fstring(self): yield self.st, """x = 42; z = f'ab{x}cd'""", 'z', 'ab42cd' +yield self.st, """z = f'{{'""", 'z', '{' +yield self.st, """z = f'}}'""", 'z', '}' +yield self.st, """z = f'x{{y'""", 'z', 'x{y' +yield self.st, """z = f'x}}y'""", 'z', 'x}y' + +yield self.st, """x = 'hi'; z = f'{x}'""", 'z', 'hi' +yield self.st, """x = 'hi'; z = f'{x!s}'""", 'z', 'hi' +yield self.st, """x = 'hi'; z = f'{x!r}'""", 'z', "'hi'" +yield self.st, """x = 'hi'; z = f'{x!a}'""", 'z', "'hi'" class AppTestCompiler: diff --git a/pypy/interpreter/pyopcode.py b/pypy/interpreter/pyopcode.py --- a/pypy/interpreter/pyopcode.py +++ b/pypy/interpreter/pyopcode.py @@ -1612,8 +1612,19 @@ self.pushvalue(w_awaitable) def FORMAT_VALUE(self, oparg, next_instr): +from pypy.interpreter.astcompiler import consts space = self.space w_value = self.popvalue() +# +conversion = oparg & consts.FVC_MASK +if conversion == consts.FVC_STR: +w_value = space.str(w_value) +elif conversion == consts.FVC_REPR: +w_value = space.repr(w_value) +elif conversion == consts.FVC_ASCII: +from
[pypy-commit] pypy py3.5-fstring-pep498: bytecode interpreter
Author: Armin RigoBranch: py3.5-fstring-pep498 Changeset: r89697:fa0095403f9d Date: 2017-01-22 22:48 +0100 http://bitbucket.org/pypy/pypy/changeset/fa0095403f9d/ Log:bytecode interpreter diff --git a/lib-python/3/opcode.py b/lib-python/3/opcode.py --- a/lib-python/3/opcode.py +++ b/lib-python/3/opcode.py @@ -214,8 +214,8 @@ def_op('BUILD_TUPLE_UNPACK', 152) def_op('BUILD_SET_UNPACK', 153) -def_op('FORMAT_VALUE', 155) -def_op('BUILD_STRING', 157) +def_op('FORMAT_VALUE', 155) # in CPython 3.6, but available in PyPy from 3.5 +def_op('BUILD_STRING', 157) # in CPython 3.6, but available in PyPy from 3.5 # pypy modification, experimental bytecode def_op('LOOKUP_METHOD', 201) # Index in name list diff --git a/pypy/interpreter/astcompiler/assemble.py b/pypy/interpreter/astcompiler/assemble.py --- a/pypy/interpreter/astcompiler/assemble.py +++ b/pypy/interpreter/astcompiler/assemble.py @@ -758,6 +758,13 @@ def _compute_CALL_METHOD(arg): return -_num_args(arg) - 1 +def _compute_FORMAT_VALUE(arg): +#if arg contains some flag: return -1 +return 0 + +def _compute_BUILD_STRING(arg): +return 1 - arg + _stack_effect_computers = {} for name, func in globals().items(): diff --git a/pypy/interpreter/astcompiler/astbuilder.py b/pypy/interpreter/astcompiler/astbuilder.py --- a/pypy/interpreter/astcompiler/astbuilder.py +++ b/pypy/interpreter/astcompiler/astbuilder.py @@ -1286,18 +1286,18 @@ else: self.error("f-string: unexpected '}'", atom_node) continue +self._f_constant_string(joined_pieces, u[start:p1], atom_node) if p1 == len(u): -self._f_constant_string(joined_pieces, u[start:], atom_node) break # no more '{' or '}' left pn = p1 + 1 if pn < len(u) and u[pn] == u'{':# '{{' => single '{' -self._f_constant_string(joined_pieces, u[start:pn], atom_node) -start = pn + 1 +start = pn +p1 = u.find(u'{', start + 1) else: assert u[p1] == u'{' start = self._f_string_expr(joined_pieces, u, pn, atom_node) assert u[start - 1] == u'}' -p1 = u.find(u'{', start) +p1 = u.find(u'{', start) def handle_atom(self, atom_node): first_child = atom_node.get_child(0) diff --git a/pypy/interpreter/astcompiler/test/test_compiler.py b/pypy/interpreter/astcompiler/test/test_compiler.py --- a/pypy/interpreter/astcompiler/test/test_compiler.py +++ b/pypy/interpreter/astcompiler/test/test_compiler.py @@ -12,7 +12,7 @@ p = pyparse.PythonParser(space) info = pyparse.CompileInfo("", mode) cst = p.parse_source(expr, info) -ast = astbuilder.ast_from_node(space, cst, info) +ast = astbuilder.ast_from_node(space, cst, info, recursive_parser=p) return codegen.compile_ast(space, ast, info) def generate_function_code(expr, space): @@ -1162,6 +1162,9 @@ """ yield self.st, source, "f()", 43 +def test_fstring(self): +yield self.st, """x = 42; z = f'ab{x}cd'""", 'z', 'ab42cd' + class AppTestCompiler: diff --git a/pypy/interpreter/pyopcode.py b/pypy/interpreter/pyopcode.py --- a/pypy/interpreter/pyopcode.py +++ b/pypy/interpreter/pyopcode.py @@ -434,6 +434,10 @@ self.GET_AITER(oparg, next_instr) elif opcode == opcodedesc.GET_ANEXT.index: self.GET_ANEXT(oparg, next_instr) +elif opcode == opcodedesc.FORMAT_VALUE.index: +self.FORMAT_VALUE(oparg, next_instr) +elif opcode == opcodedesc.BUILD_STRING.index: +self.BUILD_STRING(oparg, next_instr) else: self.MISSING_OPCODE(oparg, next_instr) @@ -1607,6 +1611,23 @@ "from __anext__: %T", w_next_iter) self.pushvalue(w_awaitable) +def FORMAT_VALUE(self, oparg, next_instr): +space = self.space +w_value = self.popvalue() +w_res = space.format(w_value, space.newunicode(u'')) +self.pushvalue(w_res) + +@jit.unroll_safe +def BUILD_STRING(self, itemcount, next_instr): +space = self.space +lst = [] +for i in range(itemcount-1, -1, -1): +w_item = self.peekvalue(i) +lst.append(space.unicode_w(w_item)) +self.dropvalues(itemcount) +w_res = space.newunicode(u''.join(lst)) +self.pushvalue(w_res) + ### ### class ExitFrame(Exception): ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.5-fstring-pep498: ast -> bytecode, minimal
Author: Armin RigoBranch: py3.5-fstring-pep498 Changeset: r89696:f23c6257063a Date: 2017-01-22 21:47 +0100 http://bitbucket.org/pypy/pypy/changeset/f23c6257063a/ Log:ast -> bytecode, minimal diff --git a/lib-python/3/opcode.py b/lib-python/3/opcode.py --- a/lib-python/3/opcode.py +++ b/lib-python/3/opcode.py @@ -214,6 +214,9 @@ def_op('BUILD_TUPLE_UNPACK', 152) def_op('BUILD_SET_UNPACK', 153) +def_op('FORMAT_VALUE', 155) +def_op('BUILD_STRING', 157) + # pypy modification, experimental bytecode def_op('LOOKUP_METHOD', 201) # Index in name list hasname.append(201) diff --git a/pypy/interpreter/astcompiler/astbuilder.py b/pypy/interpreter/astcompiler/astbuilder.py --- a/pypy/interpreter/astcompiler/astbuilder.py +++ b/pypy/interpreter/astcompiler/astbuilder.py @@ -1232,6 +1232,7 @@ def _f_string_expr(self, joined_pieces, u, start, atom_node): conversion = -1 # the conversion char. -1 if not specified. +format_spec = None nested_depth = 0# nesting level for braces/parens/brackets in exprs p = start while p < len(u): @@ -1261,7 +1262,10 @@ assert p >= start expr = self._f_string_compile(u[start:p], atom_node) assert isinstance(expr, ast.Expression) -joined_pieces.append(expr.body) +fval = ast.FormattedValue(expr.body, conversion, format_spec, + atom_node.get_lineno(), + atom_node.get_column()) +joined_pieces.append(fval) return end_f_string def _parse_f_string(self, joined_pieces, w_string, atom_node): diff --git a/pypy/interpreter/astcompiler/codegen.py b/pypy/interpreter/astcompiler/codegen.py --- a/pypy/interpreter/astcompiler/codegen.py +++ b/pypy/interpreter/astcompiler/codegen.py @@ -1491,6 +1491,16 @@ sub.value.walkabout(self) self._compile_slice(sub.slice, sub.ctx) +def visit_JoinedStr(self, joinedstr): +self.update_position(joinedstr.lineno) +for node in joinedstr.values: +node.walkabout(self) +self.emit_op_arg(ops.BUILD_STRING, len(joinedstr.values)) + +def visit_FormattedValue(self, fmt): +fmt.value.walkabout(self) +self.emit_op_arg(ops.FORMAT_VALUE, 0) + class TopLevelCodeGenerator(PythonCodeGenerator): diff --git a/pypy/interpreter/astcompiler/validate.py b/pypy/interpreter/astcompiler/validate.py --- a/pypy/interpreter/astcompiler/validate.py +++ b/pypy/interpreter/astcompiler/validate.py @@ -447,3 +447,11 @@ node.single is not space.w_True and node.single is not space.w_False): raise ValidationError("singleton must be True, False, or None") + +def visit_JoinedStr(self, node): +self._validate_exprs(node.values) + +def visit_FormattedValue(self, node): +self._validate_expr(node.value) +if node.format_spec: +self._validate_expr(node.format_spec) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.5-fstring-pep498: in-progress: turn a simple f-string to AST
Author: Armin RigoBranch: py3.5-fstring-pep498 Changeset: r89695:4b57696884e6 Date: 2017-01-22 21:31 +0100 http://bitbucket.org/pypy/pypy/changeset/4b57696884e6/ Log:in-progress: turn a simple f-string to AST diff --git a/pypy/interpreter/astcompiler/astbuilder.py b/pypy/interpreter/astcompiler/astbuilder.py --- a/pypy/interpreter/astcompiler/astbuilder.py +++ b/pypy/interpreter/astcompiler/astbuilder.py @@ -7,9 +7,9 @@ from rpython.rlib.objectmodel import always_inline, we_are_translated -def ast_from_node(space, node, compile_info): +def ast_from_node(space, node, compile_info, recursive_parser=None): """Turn a parse tree, node, to AST.""" -ast = ASTBuilder(space, node, compile_info).build_ast() +ast = ASTBuilder(space, node, compile_info, recursive_parser).build_ast() # # When we are not translated, we send this ast to validate_ast. # The goal is to check that validate_ast doesn't crash on valid @@ -54,10 +54,11 @@ class ASTBuilder(object): -def __init__(self, space, n, compile_info): +def __init__(self, space, n, compile_info, recursive_parser=None): self.space = space self.compile_info = compile_info self.root_node = n +self.recursive_parser = recursive_parser def build_ast(self): """Convert an top level parse tree node into an AST mod.""" @@ -1206,40 +1207,93 @@ joined_pieces.append(node(w_string, atom_node.get_lineno(), atom_node.get_column())) -def _f_string_expr(self, joined_pieces, u, start, atom_node): +def _f_constant_string(self, joined_pieces, u, atom_node): +self._add_constant_string(joined_pieces, self.space.newunicode(u), + atom_node) + +def _f_string_compile(self, source, atom_node): # Note: a f-string is kept as a single literal up to here. # At this point only, we recursively call the AST compiler # on all the '{expr}' parts. The 'expr' part is not parsed # or even tokenized together with the rest of the source code! -... +from pypy.interpreter.pyparser import pyparse + +if self.recursive_parser is None: +self.error("internal error: parser not available for parsing " + "the expressions inside the f-string", atom_node) +source = source.encode('utf-8') + +info = pyparse.CompileInfo("", "eval", + consts.PyCF_SOURCE_IS_UTF8 | + consts.PyCF_IGNORE_COOKIE, + optimize=self.compile_info.optimize) +parse_tree = self.recursive_parser.parse_source(source, info) +return ast_from_node(self.space, parse_tree, info) + +def _f_string_expr(self, joined_pieces, u, start, atom_node): +conversion = -1 # the conversion char. -1 if not specified. +nested_depth = 0# nesting level for braces/parens/brackets in exprs +p = start +while p < len(u): +ch = u[p] +p += 1 +if ch in u'[{(': +nested_depth += 1 +elif nested_depth > 0 and ch in u']})': +nested_depth -= 1 +elif nested_depth == 0 and ch in u'!:}': +# special-case '!=' +if ch == u'!' and p < len(u) and u[p] == u'=': +continue +break # normal way out of this loop +# XXX forbid comment, but how? +else: +raise self.error("f-string: unterminated '{' expression") +if nested_depth > 0: +self.error("f-string: mismatched '(', '{' or '['") +if ch == u'!': +XXX +if ch == u':': +XXX +assert ch == u'}' +end_f_string = p +p -= 1 # drop the final '}' +assert p >= start +expr = self._f_string_compile(u[start:p], atom_node) +assert isinstance(expr, ast.Expression) +joined_pieces.append(expr.body) +return end_f_string def _parse_f_string(self, joined_pieces, w_string, atom_node): space = self.space u = space.unicode_w(w_string) -conversion = -1 # the conversion char. -1 if not specified. -nested_depth = 0# nesting level for braces/parens/brackets in exprs start = 0 p1 = u.find(u'{') -p2 = u.find(u'}') -while p1 >= 0 or p2 >= 0: -if p1 >= 0 and (p2 < 0 or p1 < p2): -pn = p1 + 1 -if pn < len(u) and u[pn] == u'{':# '{{' => single '{' -self._add_constant_string(space.newunicode(u[start:pn])) +while True: +if p1 < 0: +p1 = len(u) +p2 = u.find(u'}', start, p1) +if p2 >= 0: +pn = p2 + 1 +if pn < len(u) and u[pn] == u'}':#
[pypy-commit] pypy default: replicate obscure CPython package loading behavior
Author: Benjamin PetersonBranch: Changeset: r89693:b289308aa50b Date: 2017-01-22 12:04 -0800 http://bitbucket.org/pypy/pypy/changeset/b289308aa50b/ Log:replicate obscure CPython package loading behavior 1. When searching for an __init__ file, CPython checks for __init__.py and __init__.py[co] but not __init__.so or __init__.pyw. 2. CPython considers any __init__\.py[oc]? entry it can stat successfully to qualify a directory as a package. This means __init__.py need not be a regular file and may be something weird like /dev/null (a character device). The behavior is less strange in Python 3, where __init__.py are required to be real files. diff --git a/pypy/module/imp/importing.py b/pypy/module/imp/importing.py --- a/pypy/module/imp/importing.py +++ b/pypy/module/imp/importing.py @@ -64,13 +64,26 @@ space.call_method(w_stderr, "write", space.wrap(message)) def file_exists(path): -"""Tests whether the given path is an existing regular file.""" +"Test whether the given path is an existing regular file." return os.path.isfile(path) and case_ok(path) +def path_exists(path): +"Test whether the given path exists." +return os.path.exists(path) and case_ok(path) + def has_so_extension(space): return (space.config.objspace.usemodules.cpyext or space.config.objspace.usemodules._cffi_backend) +def has_init_module(space, filepart): +"Return True if the directory filepart qualifies as a package." +init = os.path.join(filepart, "__init__") +if path_exists(init + ".py"): +return True +if space.config.objspace.lonepycfiles and path_exists(init + ".pyc"): +return True +return False + def find_modtype(space, filepart): """Check which kind of module to import for the given filepart, which is a path without extension. Returns PY_SOURCE, PY_COMPILED or @@ -565,9 +578,7 @@ filepart = os.path.join(path, partname) log_pyverbose(space, 2, "# trying %s" % (filepart,)) if os.path.isdir(filepart) and case_ok(filepart): -initfile = os.path.join(filepart, '__init__') -modtype, _, _ = find_modtype(space, initfile) -if modtype in (PY_SOURCE, PY_COMPILED): +if has_init_module(space, filepart): return FindInfo(PKG_DIRECTORY, filepart, None) else: msg = ("Not importing directory '%s' missing __init__.py" % diff --git a/pypy/module/imp/test/test_import.py b/pypy/module/imp/test/test_import.py --- a/pypy/module/imp/test/test_import.py +++ b/pypy/module/imp/test/test_import.py @@ -108,7 +108,7 @@ # create compiled/x.py and a corresponding pyc file p = setuppkg("compiled", x = "x = 84") if conftest.option.runappdirect: -import marshal, stat, struct, os, imp +import marshal, stat, struct, imp code = py.code.Source(p.join("x.py").read()).compile() s3 = marshal.dumps(code) s2 = struct.pack("
[pypy-commit] pypy default: fix typo
Author: Benjamin PetersonBranch: Changeset: r89694:21d3185f73a1 Date: 2017-01-22 12:07 -0800 http://bitbucket.org/pypy/pypy/changeset/21d3185f73a1/ Log:fix typo diff --git a/rpython/memory/gc/incminimark.py b/rpython/memory/gc/incminimark.py --- a/rpython/memory/gc/incminimark.py +++ b/rpython/memory/gc/incminimark.py @@ -2226,7 +2226,7 @@ # # 'threshold_objects_made_old', is used inside comparisons # with 'size_objects_made_old' to know when we must do -# several major GC steps (i.e. several consecurive calls +# several major GC steps (i.e. several consecutive calls # to the present function). Here is the target that # we try to aim to: either (A1) or (A2) # ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.5-fstring-pep498: in-progress
Author: Armin RigoBranch: py3.5-fstring-pep498 Changeset: r89692:533c8eeffd5b Date: 2017-01-22 20:26 +0100 http://bitbucket.org/pypy/pypy/changeset/533c8eeffd5b/ Log:in-progress diff --git a/pypy/interpreter/astcompiler/ast.py b/pypy/interpreter/astcompiler/ast.py --- a/pypy/interpreter/astcompiler/ast.py +++ b/pypy/interpreter/astcompiler/ast.py @@ -1670,6 +1670,10 @@ return Num.from_object(space, w_node) if space.isinstance_w(w_node, get(space).w_Str): return Str.from_object(space, w_node) +if space.isinstance_w(w_node, get(space).w_FormattedValue): +return FormattedValue.from_object(space, w_node) +if space.isinstance_w(w_node, get(space).w_JoinedStr): +return JoinedStr.from_object(space, w_node) if space.isinstance_w(w_node, get(space).w_Bytes): return Bytes.from_object(space, w_node) if space.isinstance_w(w_node, get(space).w_NameConstant): @@ -2554,6 +2558,98 @@ State.ast_type('Str', 'expr', ['s']) +class FormattedValue(expr): + +def __init__(self, value, conversion, format_spec, lineno, col_offset): +self.value = value +self.conversion = conversion +self.format_spec = format_spec +expr.__init__(self, lineno, col_offset) + +def walkabout(self, visitor): +visitor.visit_FormattedValue(self) + +def mutate_over(self, visitor): +self.value = self.value.mutate_over(visitor) +if self.format_spec: +self.format_spec = self.format_spec.mutate_over(visitor) +return visitor.visit_FormattedValue(self) + +def to_object(self, space): +w_node = space.call_function(get(space).w_FormattedValue) +w_value = self.value.to_object(space) # expr +space.setattr(w_node, space.wrap('value'), w_value) +w_conversion = space.wrap(self.conversion) # int +space.setattr(w_node, space.wrap('conversion'), w_conversion) +w_format_spec = self.format_spec.to_object(space) if self.format_spec is not None else space.w_None # expr +space.setattr(w_node, space.wrap('format_spec'), w_format_spec) +w_lineno = space.wrap(self.lineno) # int +space.setattr(w_node, space.wrap('lineno'), w_lineno) +w_col_offset = space.wrap(self.col_offset) # int +space.setattr(w_node, space.wrap('col_offset'), w_col_offset) +return w_node + +@staticmethod +def from_object(space, w_node): +w_value = get_field(space, w_node, 'value', False) +w_conversion = get_field(space, w_node, 'conversion', True) +w_format_spec = get_field(space, w_node, 'format_spec', True) +w_lineno = get_field(space, w_node, 'lineno', False) +w_col_offset = get_field(space, w_node, 'col_offset', False) +_value = expr.from_object(space, w_value) +if _value is None: +raise_required_value(space, w_node, 'value') +_conversion = space.int_w(w_conversion) +_format_spec = expr.from_object(space, w_format_spec) +_lineno = space.int_w(w_lineno) +_col_offset = space.int_w(w_col_offset) +return FormattedValue(_value, _conversion, _format_spec, _lineno, _col_offset) + +State.ast_type('FormattedValue', 'expr', ['value', 'conversion', 'format_spec']) + + +class JoinedStr(expr): + +def __init__(self, values, lineno, col_offset): +self.values = values +expr.__init__(self, lineno, col_offset) + +def walkabout(self, visitor): +visitor.visit_JoinedStr(self) + +def mutate_over(self, visitor): +if self.values: +visitor._mutate_sequence(self.values) +return visitor.visit_JoinedStr(self) + +def to_object(self, space): +w_node = space.call_function(get(space).w_JoinedStr) +if self.values is None: +values_w = [] +else: +values_w = [node.to_object(space) for node in self.values] # expr +w_values = space.newlist(values_w) +space.setattr(w_node, space.wrap('values'), w_values) +w_lineno = space.wrap(self.lineno) # int +space.setattr(w_node, space.wrap('lineno'), w_lineno) +w_col_offset = space.wrap(self.col_offset) # int +space.setattr(w_node, space.wrap('col_offset'), w_col_offset) +return w_node + +@staticmethod +def from_object(space, w_node): +w_values = get_field(space, w_node, 'values', False) +w_lineno = get_field(space, w_node, 'lineno', False) +w_col_offset = get_field(space, w_node, 'col_offset', False) +values_w = space.unpackiterable(w_values) +_values = [expr.from_object(space, w_item) for w_item in values_w] +_lineno = space.int_w(w_lineno) +_col_offset = space.int_w(w_col_offset) +return JoinedStr(_values, _lineno, _col_offset) + +State.ast_type('JoinedStr', 'expr', ['values']) + + class Bytes(expr): def
[pypy-commit] pypy py3.5-fstring-pep498: A branch to do f-strings from PEP 498 "Literal String Interpolation".
Author: Armin RigoBranch: py3.5-fstring-pep498 Changeset: r89691:29a1a30c2afd Date: 2017-01-22 18:20 +0100 http://bitbucket.org/pypy/pypy/changeset/29a1a30c2afd/ Log:A branch to do f-strings from PEP 498 "Literal String Interpolation". Even though they are a 3.6 feature, I see only benefits in doing it in 3.5. It can be disabled or not merged in py3.5 if we decide otherwise. ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.5: Remove a define that is very confusing on Python 3
Author: Ronan LamyBranch: py3.5 Changeset: r89690:37af509195dc Date: 2017-01-22 18:30 + http://bitbucket.org/pypy/pypy/changeset/37af509195dc/ Log:Remove a define that is very confusing on Python 3 diff --git a/pypy/module/cpyext/include/object.h b/pypy/module/cpyext/include/object.h --- a/pypy/module/cpyext/include/object.h +++ b/pypy/module/cpyext/include/object.h @@ -115,8 +115,6 @@ #include -#define PyObject_Bytes PyObject_Str - /* Flag bits for printing: */ #define Py_PRINT_RAW1 /* No string quotes etc. */ ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.5: Check for closed files before doing peek(). Also, remove _check_init
Author: Armin RigoBranch: py3.5 Changeset: r89689:e56a1d211ebe Date: 2017-01-22 17:56 +0100 http://bitbucket.org/pypy/pypy/changeset/e56a1d211ebe/ Log:Check for closed files before doing peek(). Also, remove _check_init right before _check_closed because the latter does the former too diff --git a/pypy/module/_io/interp_bufferedio.py b/pypy/module/_io/interp_bufferedio.py --- a/pypy/module/_io/interp_bufferedio.py +++ b/pypy/module/_io/interp_bufferedio.py @@ -305,11 +305,10 @@ @unwrap_spec(pos=r_longlong, whence=int) def seek_w(self, space, pos, whence=0): -self._check_init(space) +self._check_closed(space, "seek of closed file") if whence not in (0, 1, 2): raise oefmt(space.w_ValueError, "whence must be between 0 and 2, not %d", whence) -self._check_closed(space, "seek of closed file") check_seekable_w(space, self.w_raw) if whence != 2 and self.readable: # Check if seeking leaves us inside the current buffer, so as to @@ -462,7 +461,6 @@ # Read methods def read_w(self, space, w_size=None): -self._check_init(space) self._check_closed(space, "read of closed file") size = convert_size(space, w_size) @@ -482,7 +480,7 @@ @unwrap_spec(size=int) def peek_w(self, space, size=0): -self._check_init(space) +self._check_closed(space, "peek of closed file") with self.lock: if self.writable: self._flush_and_rewind_unlocked(space) @@ -509,7 +507,6 @@ @unwrap_spec(size=int) def read1_w(self, space, size): -self._check_init(space) self._check_closed(space, "read of closed file") if size < 0: @@ -690,7 +687,6 @@ return None def readline_w(self, space, w_limit=None): -self._check_init(space) self._check_closed(space, "readline of closed file") limit = convert_size(space, w_limit) @@ -766,7 +762,6 @@ self.read_end = self.pos def write_w(self, space, w_data): -self._check_init(space) self._check_closed(space, "write to closed file") data = space.getarg_w('y*', w_data).as_str() size = len(data) @@ -873,7 +868,6 @@ return space.wrap(written) def flush_w(self, space): -self._check_init(space) self._check_closed(space, "flush of closed file") with self.lock: self._flush_and_rewind_unlocked(space) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.5: Copy more closely the logic of CPython 3.5 for 'closefd' inside FileIO.__init__()
Author: Armin RigoBranch: py3.5 Changeset: r89688:983e1e1ee62f Date: 2017-01-22 17:43 +0100 http://bitbucket.org/pypy/pypy/changeset/983e1e1ee62f/ Log:Copy more closely the logic of CPython 3.5 for 'closefd' inside FileIO.__init__() diff --git a/pypy/module/_io/interp_fileio.py b/pypy/module/_io/interp_fileio.py --- a/pypy/module/_io/interp_fileio.py +++ b/pypy/module/_io/interp_fileio.py @@ -145,7 +145,12 @@ @unwrap_spec(mode=str, closefd=int) def descr_init(self, space, w_name, mode='r', closefd=True, w_opener=None): -self._close(space) +if self.fd >= 0: +if self.closefd: +self._close(space) +else: +self.fd = -1 + if space.isinstance_w(w_name, space.w_float): raise oefmt(space.w_TypeError, "integer argument expected, got float") @@ -168,48 +173,52 @@ if fd >= 0: self.fd = fd self.closefd = bool(closefd) -elif space.is_none(w_opener): +else: self.closefd = True if not closefd: raise oefmt(space.w_ValueError, "Cannot use closefd=False with file name") -from pypy.module.posix.interp_posix import dispatch_filename -while True: +if space.is_none(w_opener): +from pypy.module.posix.interp_posix import dispatch_filename +while True: +try: +self.fd = dispatch_filename(rposix.open)( +space, w_name, flags, 0666) +fd_is_own = True +break +except OSError as e: +wrap_oserror2(space, e, w_name, + exception_name='w_IOError', + eintr_retry=True) +if not rposix._WIN32: +try: +_open_inhcache.set_non_inheritable(self.fd) +except OSError as e: +raise wrap_oserror2(space, e, w_name, +eintr_retry=False) +else: +w_fd = space.call_function(w_opener, w_name, + space.wrap(flags)) try: -self.fd = dispatch_filename(rposix.open)( -space, w_name, flags, 0666) +self.fd = space.int_w(w_fd) +if self.fd < 0: +# The opener returned a negative result instead +# of raising an exception +raise oefmt(space.w_ValueError, +"opener returned %d", self.fd) fd_is_own = True -break -except OSError as e: -wrap_oserror2(space, e, w_name, - exception_name='w_IOError', - eintr_retry=True) -if not rposix._WIN32: -try: -_open_inhcache.set_non_inheritable(self.fd) -except OSError as e: -raise wrap_oserror2(space, e, w_name, eintr_retry=False) -else: -w_fd = space.call_function(w_opener, w_name, space.wrap(flags)) -try: -self.fd = space.int_w(w_fd) -if self.fd < 0: -# The opener returned a negative result instead -# of raising an exception -raise oefmt(space.w_ValueError, -"opener returned %d", self.fd) -fd_is_own = True -except OperationError as e: -if not e.match(space, space.w_TypeError): -raise -raise oefmt(space.w_TypeError, -"expected integer from opener") -if not rposix._WIN32: -try: -rposix.set_inheritable(self.fd, False) -except OSError as e: -raise wrap_oserror2(space, e, w_name, eintr_retry=False) +except OperationError as e: +if not e.match(space, space.w_TypeError): +raise +raise oefmt(space.w_TypeError, +"expected integer from opener") +if not rposix._WIN32: +try: +
[pypy-commit] pypy py3.5: hg merge default
Author: Armin RigoBranch: py3.5 Changeset: r89687:82de3a7f19fe Date: 2017-01-22 17:36 +0100 http://bitbucket.org/pypy/pypy/changeset/82de3a7f19fe/ Log:hg merge default diff --git a/rpython/jit/backend/ppc/test/test_ppcvector.py b/rpython/jit/backend/ppc/test/test_ppcvector.py --- a/rpython/jit/backend/ppc/test/test_ppcvector.py +++ b/rpython/jit/backend/ppc/test/test_ppcvector.py @@ -1,10 +1,10 @@ import py from rpython.jit.backend.ppc.test import test_basic -from rpython.jit.metainterp.test import test_vector +from rpython.jit.metainterp.test import test_zvector from rpython.jit.backend.ppc.detect_feature import detect_vsx -class TestBasic(test_basic.JitPPCMixin, test_vector.VectorizeTests): +class TestBasic(test_basic.JitPPCMixin, test_zvector.VectorizeTests): # for the individual tests see # > ../../../metainterp/test/test_basic.py def setup_method(self, method): diff --git a/rpython/jit/backend/x86/test/test_x86vector.py b/rpython/jit/backend/x86/test/test_x86vector.py --- a/rpython/jit/backend/x86/test/test_x86vector.py +++ b/rpython/jit/backend/x86/test/test_x86vector.py @@ -6,11 +6,11 @@ from rpython.jit.backend.x86.test import test_basic from rpython.jit.backend.x86.test.test_assembler import \ (TestRegallocPushPop as BaseTestAssembler) -from rpython.jit.metainterp.test import test_vector +from rpython.jit.metainterp.test import test_zvector from rpython.rtyper.lltypesystem import lltype from rpython.jit.backend.detect_cpu import getcpuclass -class TestBasic(test_basic.Jit386Mixin, test_vector.VectorizeTests): +class TestBasic(test_basic.Jit386Mixin, test_zvector.VectorizeTests): # for the individual tests see # > ../../../metainterp/test/test_basic.py def setup_method(self, method): diff --git a/rpython/jit/backend/zarch/test/test_zarchvector.py b/rpython/jit/backend/zarch/test/test_zarchvector.py --- a/rpython/jit/backend/zarch/test/test_zarchvector.py +++ b/rpython/jit/backend/zarch/test/test_zarchvector.py @@ -1,10 +1,10 @@ import py from rpython.jit.backend.zarch.test import test_basic -from rpython.jit.metainterp.test import test_vector +from rpython.jit.metainterp.test import test_zvector from rpython.jit.backend.zarch.detect_feature import detect_simd_z -class TestBasic(test_basic.JitZARCHMixin, test_vector.VectorizeTests): +class TestBasic(test_basic.JitZARCHMixin, test_zvector.VectorizeTests): # for the individual tests see # > ../../../metainterp/test/test_basic.py def setup_method(self, method): ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy nogil-unsafe: tweak
Author: Armin RigoBranch: nogil-unsafe Changeset: r89685:e8a2d7c06655 Date: 2017-01-21 11:12 +0100 http://bitbucket.org/pypy/pypy/changeset/e8a2d7c06655/ Log:tweak diff --git a/rpython/memory/gc/incminimark.py b/rpython/memory/gc/incminimark.py --- a/rpython/memory/gc/incminimark.py +++ b/rpython/memory/gc/incminimark.py @@ -879,9 +879,11 @@ self.nublocks = rthread.get_threadlocal_base() else: if llop.get_gil_share_count(lltype.Signed) > 1: -assert old_color == 0 +self._gc_unlock() +ll_assert(old_color == 0, "old_color != 0") old_color = llop.get_gil_color(lltype.Signed) llop.set_gil_color(lltype.Void, self.gil_gc_color) +self._gc_lock() continue # waited, maybe the situation changed minor_collection_count += 1 if minor_collection_count == 1: ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: fix tests that import test_vector
Author: Armin RigoBranch: Changeset: r89686:858ae6e5cbfe Date: 2017-01-22 17:35 +0100 http://bitbucket.org/pypy/pypy/changeset/858ae6e5cbfe/ Log:fix tests that import test_vector diff --git a/rpython/jit/backend/ppc/test/test_ppcvector.py b/rpython/jit/backend/ppc/test/test_ppcvector.py --- a/rpython/jit/backend/ppc/test/test_ppcvector.py +++ b/rpython/jit/backend/ppc/test/test_ppcvector.py @@ -1,10 +1,10 @@ import py from rpython.jit.backend.ppc.test import test_basic -from rpython.jit.metainterp.test import test_vector +from rpython.jit.metainterp.test import test_zvector from rpython.jit.backend.ppc.detect_feature import detect_vsx -class TestBasic(test_basic.JitPPCMixin, test_vector.VectorizeTests): +class TestBasic(test_basic.JitPPCMixin, test_zvector.VectorizeTests): # for the individual tests see # > ../../../metainterp/test/test_basic.py def setup_method(self, method): diff --git a/rpython/jit/backend/x86/test/test_x86vector.py b/rpython/jit/backend/x86/test/test_x86vector.py --- a/rpython/jit/backend/x86/test/test_x86vector.py +++ b/rpython/jit/backend/x86/test/test_x86vector.py @@ -6,11 +6,11 @@ from rpython.jit.backend.x86.test import test_basic from rpython.jit.backend.x86.test.test_assembler import \ (TestRegallocPushPop as BaseTestAssembler) -from rpython.jit.metainterp.test import test_vector +from rpython.jit.metainterp.test import test_zvector from rpython.rtyper.lltypesystem import lltype from rpython.jit.backend.detect_cpu import getcpuclass -class TestBasic(test_basic.Jit386Mixin, test_vector.VectorizeTests): +class TestBasic(test_basic.Jit386Mixin, test_zvector.VectorizeTests): # for the individual tests see # > ../../../metainterp/test/test_basic.py def setup_method(self, method): diff --git a/rpython/jit/backend/zarch/test/test_zarchvector.py b/rpython/jit/backend/zarch/test/test_zarchvector.py --- a/rpython/jit/backend/zarch/test/test_zarchvector.py +++ b/rpython/jit/backend/zarch/test/test_zarchvector.py @@ -1,10 +1,10 @@ import py from rpython.jit.backend.zarch.test import test_basic -from rpython.jit.metainterp.test import test_vector +from rpython.jit.metainterp.test import test_zvector from rpython.jit.backend.zarch.detect_feature import detect_simd_z -class TestBasic(test_basic.JitZARCHMixin, test_vector.VectorizeTests): +class TestBasic(test_basic.JitZARCHMixin, test_zvector.VectorizeTests): # for the individual tests see # > ../../../metainterp/test/test_basic.py def setup_method(self, method): ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy.org extradoc: update the values
Author: Armin RigoBranch: extradoc Changeset: r849:e655714ca28f Date: 2017-01-22 17:02 +0100 http://bitbucket.org/pypy/pypy.org/changeset/e655714ca28f/ Log:update the values diff --git a/don1.html b/don1.html --- a/don1.html +++ b/don1.html @@ -15,7 +15,7 @@ - $66569 of $105000 (63.4%) + $66570 of $105000 (63.4%) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit