[pypy-commit] pypy strbuf-as-buffer: expose a function to check if a W_Buffer is readonly or not (ctypes from_buffer functions needs to check that)
Author: Richard Plangger Branch: strbuf-as-buffer Changeset: r89261:530e24e0fbd0 Date: 2016-12-29 13:04 +0100 http://bitbucket.org/pypy/pypy/changeset/530e24e0fbd0/ Log:expose a function to check if a W_Buffer is readonly or not (ctypes from_buffer functions needs to check that) diff --git a/lib_pypy/_ctypes/basics.py b/lib_pypy/_ctypes/basics.py --- a/lib_pypy/_ctypes/basics.py +++ b/lib_pypy/_ctypes/basics.py @@ -85,8 +85,8 @@ def from_buffer(self, obj, offset=0): size = self._sizeofinstances() -buf = memoryview(obj)[offset:] -if buf.readonly: +buf = buffer(obj, offset, size) +if buf._pypy_is_readonly(): raise TypeError("Cannot use %s as modifiable buffer" % str(type(obj))) if len(buf) < size: raise ValueError( diff --git a/pypy/objspace/std/bufferobject.py b/pypy/objspace/std/bufferobject.py --- a/pypy/objspace/std/bufferobject.py +++ b/pypy/objspace/std/bufferobject.py @@ -138,6 +138,11 @@ raise OperationError(space.w_ValueError, space.wrap(msg)) return space.wrap(rffi.cast(lltype.Signed, ptr)) +def descr_is_readonly(self, space): +""" Needed in ctypes (from_buffer), CPython can check if a +buffer can be readonly (has a C Function/Macro for that) """ +return space.newbool(bool(self.buf.readonly)) + W_Buffer.typedef = TypeDef( "buffer", None, None, "read-write", __doc__ = """\ @@ -166,5 +171,6 @@ __repr__ = interp2app(W_Buffer.descr_repr), __buffer__ = interp2app(W_Buffer.descr_getbuffer), _pypy_raw_address = interp2app(W_Buffer.descr_pypy_raw_address), +_pypy_is_readonly = interp2app(W_Buffer.descr_is_readonly), ) W_Buffer.typedef.acceptable_as_base_class = False ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy.org extradoc: fix link
Author: Armin Rigo Branch: extradoc Changeset: r839:03a87c8a2ff4 Date: 2016-12-29 13:41 +0100 http://bitbucket.org/pypy/pypy.org/changeset/03a87c8a2ff4/ Log:fix link diff --git a/download.html b/download.html --- a/download.html +++ b/download.html @@ -77,7 +77,7 @@ We provide binaries for x86, ARM, and PPC Linux, Mac OS/X and Windows for: the Python2.7 compatible release — PyPy2.7 v5.6.0 — (http://doc.pypy.org/en/latest/release-pypy2.7-v5.6.0.html";>what's new in PyPy2.7?) -the Python3.3 compatible release — PyPy3.3 v5.5 — (http://doc.pypy.org/en/latest/release-pypy3.3-v5.5-alpha.html";>what's new in PyPy3.3?). +the Python3.3 compatible release — PyPy3.3 v5.5 — (http://doc.pypy.org/en/latest/release-pypy3.3-v5.5.0.html";>what's new in PyPy3.3?). the Python2.7 Software Transactional Memory special release — PyPy-STM 2.5.1 (Linux x86-64 only) diff --git a/source/download.txt b/source/download.txt --- a/source/download.txt +++ b/source/download.txt @@ -21,7 +21,7 @@ * the Python2.7 Software Transactional Memory special release — **PyPy-STM 2.5.1** (Linux x86-64 only) .. _what's new in PyPy2.7?: http://doc.pypy.org/en/latest/release-pypy2.7-v5.6.0.html -.. _what's new in PyPy3.3?: http://doc.pypy.org/en/latest/release-pypy3.3-v5.5-alpha.html +.. _what's new in PyPy3.3?: http://doc.pypy.org/en/latest/release-pypy3.3-v5.5.0.html .. class:: download_menu ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy py3.5: rStringIO assert that during tests the slicing is within bounds, extend a test to check readline returns empty string if the position is out of bounds
Author: Richard Plangger Branch: py3.5 Changeset: r89263:c7076180efda Date: 2016-12-29 14:50 +0100 http://bitbucket.org/pypy/pypy/changeset/c7076180efda/ Log:rStringIO assert that during tests the slicing is within bounds, extend a test to check readline returns empty string if the position is out of bounds diff --git a/rpython/rlib/rStringIO.py b/rpython/rlib/rStringIO.py --- a/rpython/rlib/rStringIO.py +++ b/rpython/rlib/rStringIO.py @@ -1,4 +1,5 @@ from rpython.rlib.rstring import StringBuilder +from rpython.rlib.objectmodel import we_are_translated AT_END = -1 @@ -154,8 +155,11 @@ assert p >= 0 self.__copy_into_bigbuffer() end = len(self.__bigbuffer) -if size >= 0 and size < end - p: +count = end - p +if size >= 0 and size < count: end = p + size +if count <= 0: +return '' i = p while i < end: finished = self.__bigbuffer[i] == '\n' @@ -163,6 +167,11 @@ if finished: break self.__pos = i +if not we_are_translated(): +# assert that we read within the bounds! +bl = len(self.__bigbuffer) +assert p <= bl +assert i <= bl return ''.join(self.__bigbuffer[p:i]) def truncate(self, size): diff --git a/rpython/rlib/test/test_rStringIO.py b/rpython/rlib/test/test_rStringIO.py --- a/rpython/rlib/test/test_rStringIO.py +++ b/rpython/rlib/test/test_rStringIO.py @@ -91,6 +91,10 @@ assert f.readline() == 'baz' assert f.readline() == '' +f.seek(10, 0) +assert f.tell() == 10 +assert f.readline() == '' + def test_truncate(): f = RStringIO() f.truncate(20) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy strbuf-as-buffer: merge default
Author: Richard Plangger Branch: strbuf-as-buffer Changeset: r89262:8e166d469274 Date: 2016-12-29 13:09 +0100 http://bitbucket.org/pypy/pypy/changeset/8e166d469274/ Log:merge default diff too long, truncating to 2000 out of 3046 lines diff --git a/ctypes_configure/__init__.py b/ctypes_configure/__init__.py deleted file mode 100644 diff --git a/ctypes_configure/cbuild.py b/ctypes_configure/cbuild.py deleted file mode 100644 --- a/ctypes_configure/cbuild.py +++ /dev/null @@ -1,456 +0,0 @@ - -import os, sys, inspect, re, imp, py -from ctypes_configure import stdoutcapture -import distutils - -debug = 0 - -configdir = py.path.local.make_numbered_dir(prefix='ctypes_configure-') - -class ExternalCompilationInfo(object): - -_ATTRIBUTES = ['pre_include_lines', 'includes', 'include_dirs', - 'post_include_lines', 'libraries', 'library_dirs', - 'separate_module_sources', 'separate_module_files'] -_AVOID_DUPLICATES = ['separate_module_files', 'libraries', 'includes', - 'include_dirs', 'library_dirs', 'separate_module_sources'] - -def __init__(self, - pre_include_lines = [], - includes= [], - include_dirs= [], - post_include_lines = [], - libraries = [], - library_dirs= [], - separate_module_sources = [], - separate_module_files = []): -""" -pre_include_lines: list of lines that should be put at the top -of the generated .c files, before any #include. They shouldn't -contain an #include themselves. - -includes: list of .h file names to be #include'd from the -generated .c files. - -include_dirs: list of dir names that is passed to the C compiler - -post_include_lines: list of lines that should be put at the top -of the generated .c files, after the #includes. - -libraries: list of library names that is passed to the linker - -library_dirs: list of dir names that is passed to the linker - -separate_module_sources: list of multiline strings that are -each written to a .c file and compiled separately and linked -later on. (If function prototypes are needed for other .c files -to access this, they can be put in post_include_lines.) - -separate_module_files: list of .c file names that are compiled -separately and linked later on. (If an .h file is needed for -other .c files to access this, it can be put in includes.) -""" -for name in self._ATTRIBUTES: -value = locals()[name] -assert isinstance(value, (list, tuple)) -setattr(self, name, tuple(value)) - -def _value(self): -return tuple([getattr(self, x) for x in self._ATTRIBUTES]) - -def __hash__(self): -return hash(self._value()) - -def __eq__(self, other): -return self.__class__ is other.__class__ and \ - self._value() == other._value() - -def __ne__(self, other): -return not self == other - -def __repr__(self): -info = [] -for attr in self._ATTRIBUTES: -val = getattr(self, attr) -info.append("%s=%s" % (attr, repr(val))) -return "" % ", ".join(info) - -def merge(self, *others): -others = list(others) -attrs = {} -for name in self._ATTRIBUTES: -if name not in self._AVOID_DUPLICATES: -s = [] -for i in [self] + others: -s += getattr(i, name) -attrs[name] = s -else: -s = set() -attr = [] -for one in [self] + others: -for elem in getattr(one, name): -if elem not in s: -s.add(elem) -attr.append(elem) -attrs[name] = attr -return ExternalCompilationInfo(**attrs) - -def write_c_header(self, fileobj): -for line in self.pre_include_lines: -print >> fileobj, line -for path in self.includes: -print >> fileobj, '#include <%s>' % (path,) -for line in self.post_include_lines: -print >> fileobj, line - -def _copy_attributes(self): -d = {} -for attr in self._ATTRIBUTES: -d[attr] = getattr(self, attr) -return d - -def convert_sources_to_files(self, cache_dir=None, being_main=False): -if not self.separate_module_sources: -return self -if cache_dir is None: -cache_dir = configdir.join('module_cache').ensure(dir=1) -num = 0 -files = [] -for source in self.separate_module_sources: -while 1: -filename = cache_dir.join('module_%d.c' % nu
[pypy-commit] pypy py3.5: do not skip ssl tests, _ssl module is now in lib_pypy
Author: Richard Plangger Branch: py3.5 Changeset: r89264:fb49af41edfd Date: 2016-12-29 15:02 +0100 http://bitbucket.org/pypy/pypy/changeset/fb49af41edfd/ Log:do not skip ssl tests, _ssl module is now in lib_pypy diff --git a/lib-python/conftest.py b/lib-python/conftest.py --- a/lib-python/conftest.py +++ b/lib-python/conftest.py @@ -397,7 +397,7 @@ RegrTest('test_source_encoding.py'), RegrTest('test_spwd.py'), RegrTest('test_sqlite.py', usemodules="thread _rawffi zlib"), -RegrTest('test_ssl.py', usemodules='_ssl _socket select'), +RegrTest('test_ssl.py', usemodules='_socket select'), RegrTest('test_startfile.py'), RegrTest('test_stat.py'), RegrTest('test_statistics.py'), ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Remove unused parameter
Author: Ronan Lamy Branch: Changeset: r89265:343e3390bd53 Date: 2016-12-29 15:33 +0100 http://bitbucket.org/pypy/pypy/changeset/343e3390bd53/ Log:Remove unused parameter diff --git a/pypy/module/cpyext/api.py b/pypy/module/cpyext/api.py --- a/pypy/module/cpyext/api.py +++ b/pypy/module/cpyext/api.py @@ -1076,7 +1076,7 @@ '\n' + '\n'.join(functions)) -eci = build_eci(True, export_symbols, code, use_micronumpy) +eci = build_eci(True, code, use_micronumpy) eci = eci.compile_shared_lib( outputfilename=str(udir / "module_cache" / "pypyapi")) modulename = py.path.local(eci.libraries[-1]) @@ -1341,7 +1341,7 @@ source_dir / "pymem.c", ] -def build_eci(building_bridge, export_symbols, code, use_micronumpy=False): +def build_eci(building_bridge, code, use_micronumpy=False): "NOT_RPYTHON" # Build code and get pointer to the structure kwds = {} @@ -1434,7 +1434,7 @@ code += "#include /* api.py line 1290 */\n" code += "\n".join(functions) -eci = build_eci(False, export_symbols, code, use_micronumpy) +eci = build_eci(False, code, use_micronumpy) space.fromcache(State).install_dll(eci) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Remove unused parameter
Author: Ronan Lamy Branch: Changeset: r89266:a98582230a9a Date: 2016-12-29 15:47 +0100 http://bitbucket.org/pypy/pypy/changeset/a98582230a9a/ Log:Remove unused parameter diff --git a/pypy/module/cpyext/api.py b/pypy/module/cpyext/api.py --- a/pypy/module/cpyext/api.py +++ b/pypy/module/cpyext/api.py @@ -1047,8 +1047,7 @@ RPY_EXTERN struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) -functions = generate_decls_and_callbacks(db, export_symbols, -prefix='cpyexttest') +functions = generate_decls_and_callbacks(db, prefix='cpyexttest') global_objects = [] for name, (typ, expr) in GLOBALS.iteritems(): @@ -1097,7 +1096,6 @@ run_bootstrap_functions(space) # load the bridge, and init structure -import ctypes bridge = ctypes.CDLL(str(modulename), mode=ctypes.RTLD_GLOBAL) space.fromcache(State).install_dll(eci) @@ -1224,7 +1222,7 @@ renamed_symbols = [] for name in export_symbols: if '#' in name: -name,header = name.split('#') +name, header = name.split('#') else: header = pypy_decl newname = mangle_name(prefix, name) @@ -1254,7 +1252,7 @@ pypy_macros_h = udir.join('pypy_macros.h') pypy_macros_h.write('\n'.join(pypy_macros)) -def generate_decls_and_callbacks(db, export_symbols, api_struct=True, prefix=''): +def generate_decls_and_callbacks(db, api_struct=True, prefix=''): "NOT_RPYTHON" # implement function callbacks and generate function decls functions = [] @@ -1427,8 +1425,7 @@ generate_macros(export_symbols, prefix=prefix) -functions = generate_decls_and_callbacks(db, [], api_struct=False, -prefix=prefix) +functions = generate_decls_and_callbacks(db, api_struct=False, prefix=prefix) code = "#include \n" if use_micronumpy: code += "#include /* api.py line 1290 */\n" @@ -1586,7 +1583,7 @@ @specialize.memo() def make_generic_cpy_call(FT, expect_null): -from pypy.module.cpyext.pyobject import make_ref, from_ref, Py_DecRef +from pypy.module.cpyext.pyobject import make_ref, from_ref from pypy.module.cpyext.pyobject import is_pyobj, as_pyobj from pypy.module.cpyext.pyobject import get_w_obj_and_decref from pypy.module.cpyext.pyerrors import PyErr_Occurred ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy strbuf-as-buffer: revert last commit, handle it different in _ctypes
Author: Richard Plangger Branch: strbuf-as-buffer Changeset: r89267:6381bf44e70c Date: 2016-12-29 16:34 +0100 http://bitbucket.org/pypy/pypy/changeset/6381bf44e70c/ Log:revert last commit, handle it different in _ctypes diff --git a/lib_pypy/_ctypes/basics.py b/lib_pypy/_ctypes/basics.py --- a/lib_pypy/_ctypes/basics.py +++ b/lib_pypy/_ctypes/basics.py @@ -84,10 +84,18 @@ return self.from_address(dll._handle.getaddressindll(name)) def from_buffer(self, obj, offset=0): +from array import array size = self._sizeofinstances() -buf = buffer(obj, offset, size) -if buf._pypy_is_readonly(): -raise TypeError("Cannot use %s as modifiable buffer" % str(type(obj))) +if isinstance(obj, array): +# hack, buffer(array.array) will always return a readonly buffer. +# CPython calls PyObject_AsWriteBuffer(...) here! +# array.array does not implement the buffer interface so we cannot +# use memoryview here (neither on CPython)! +buf = buffer(obj, offset, size) +else: +buf = memoryview(obj)[offset:] +if buf.readonly: +raise TypeError("Cannot use %s as modifiable buffer" % str(type(obj))) if len(buf) < size: raise ValueError( "Buffer size too small (%d instead of at least %d bytes)" diff --git a/pypy/objspace/std/bufferobject.py b/pypy/objspace/std/bufferobject.py --- a/pypy/objspace/std/bufferobject.py +++ b/pypy/objspace/std/bufferobject.py @@ -138,11 +138,6 @@ raise OperationError(space.w_ValueError, space.wrap(msg)) return space.wrap(rffi.cast(lltype.Signed, ptr)) -def descr_is_readonly(self, space): -""" Needed in ctypes (from_buffer), CPython can check if a -buffer can be readonly (has a C Function/Macro for that) """ -return space.newbool(bool(self.buf.readonly)) - W_Buffer.typedef = TypeDef( "buffer", None, None, "read-write", __doc__ = """\ @@ -171,6 +166,5 @@ __repr__ = interp2app(W_Buffer.descr_repr), __buffer__ = interp2app(W_Buffer.descr_getbuffer), _pypy_raw_address = interp2app(W_Buffer.descr_pypy_raw_address), -_pypy_is_readonly = interp2app(W_Buffer.descr_is_readonly), ) W_Buffer.typedef.acceptable_as_base_class = False ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Simplify code
Author: Ronan Lamy Branch: Changeset: r89268:7ea1e9aea7b0 Date: 2016-12-29 18:24 +0100 http://bitbucket.org/pypy/pypy/changeset/7ea1e9aea7b0/ Log:Simplify code diff --git a/pypy/module/cpyext/api.py b/pypy/module/cpyext/api.py --- a/pypy/module/cpyext/api.py +++ b/pypy/module/cpyext/api.py @@ -1,6 +1,5 @@ import ctypes import sys, os -import atexit import py @@ -18,7 +17,6 @@ from rpython.translator.tool.cbuild import ExternalCompilationInfo from rpython.translator.gensupp import NameManager from rpython.tool.udir import udir -from rpython.translator import platform from pypy.module.cpyext.state import State from pypy.interpreter.error import OperationError, oefmt from pypy.interpreter.baseobjspace import W_Root @@ -1028,6 +1026,8 @@ generate_macros(export_symbols, prefix='cpyexttest') +functions = generate_decls_and_callbacks(db, prefix='cpyexttest') + # Structure declaration code members = [] structindex = {} @@ -1047,8 +1047,6 @@ RPY_EXTERN struct PyPyAPI* pypyAPI = &_pypyAPI; """ % dict(members=structmembers) -functions = generate_decls_and_callbacks(db, prefix='cpyexttest') - global_objects = [] for name, (typ, expr) in GLOBALS.iteritems(): if '#' in name: @@ -1219,7 +1217,6 @@ def generate_macros(export_symbols, prefix): "NOT_RPYTHON" pypy_macros = [] -renamed_symbols = [] for name in export_symbols: if '#' in name: name, header = name.split('#') @@ -1231,8 +1228,6 @@ pypy_macros.append('#define %s %s' % (name, newname)) if name.startswith("PyExc_"): pypy_macros.append('#define _%s _%s' % (name, newname)) -renamed_symbols.append(newname) -export_symbols[:] = renamed_symbols # Generate defines for macro_name, size in [ ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Refactor globals registration
Author: Ronan Lamy Branch: Changeset: r89269:1e93630b441a Date: 2016-12-29 20:52 +0100 http://bitbucket.org/pypy/pypy/changeset/1e93630b441a/ Log:Refactor globals registration diff --git a/pypy/module/cpyext/api.py b/pypy/module/cpyext/api.py --- a/pypy/module/cpyext/api.py +++ b/pypy/module/cpyext/api.py @@ -482,6 +482,12 @@ TYPES[configname] = forward return forward +GLOBALS = {} +def register_global(name, typ, expr, header=None): +if header is not None: +name = '%s#%s' % (name, header) +GLOBALS[name] = (typ, expr) + INTERPLEVEL_API = {} FUNCTIONS = {} FUNCTIONS_BY_HEADER = {} @@ -542,18 +548,23 @@ '_Py_QnewFlag', 'Py_Py3kWarningFlag', 'Py_HashRandomizationFlag', '_Py_PackageContext', ] TYPES = {} -GLOBALS = { # this needs to include all prebuilt pto, otherwise segfaults occur -'_Py_NoneStruct#%s' % pypy_decl: ('PyObject*', 'space.w_None'), -'_Py_TrueStruct#%s' % pypy_decl: ('PyIntObject*', 'space.w_True'), -'_Py_ZeroStruct#%s' % pypy_decl: ('PyIntObject*', 'space.w_False'), -'_Py_NotImplementedStruct#%s' % pypy_decl: ('PyObject*', 'space.w_NotImplemented'), -'_Py_EllipsisObject#%s' % pypy_decl: ('PyObject*', 'space.w_Ellipsis'), -'PyDateTimeAPI': ('PyDateTime_CAPI*', 'None'), -} FORWARD_DECLS = [] INIT_FUNCTIONS = [] BOOTSTRAP_FUNCTIONS = [] +# this needs to include all prebuilt pto, otherwise segfaults occur +register_global('_Py_NoneStruct', +'PyObject*', 'space.w_None', header=pypy_decl) +register_global('_Py_TrueStruct', +'PyIntObject*', 'space.w_True', header=pypy_decl) +register_global('_Py_ZeroStruct', +'PyIntObject*', 'space.w_False', header=pypy_decl) +register_global('_Py_NotImplementedStruct', +'PyObject*', 'space.w_NotImplemented', header=pypy_decl) +register_global('_Py_EllipsisObject', +'PyObject*', 'space.w_Ellipsis', header=pypy_decl) +register_global('PyDateTimeAPI', 'PyDateTime_CAPI*', 'None') + def build_exported_objects(): # Standard exceptions # PyExc_BaseException, PyExc_Exception, PyExc_ValueError, PyExc_KeyError, @@ -562,7 +573,7 @@ # PyExc_NameError, PyExc_MemoryError, PyExc_RuntimeError, # PyExc_UnicodeEncodeError, PyExc_UnicodeDecodeError, ... for exc_name in exceptions.Module.interpleveldefs.keys(): -GLOBALS['PyExc_' + exc_name] = ( +register_global('PyExc_' + exc_name, 'PyTypeObject*', 'space.gettypeobject(interp_exceptions.W_%s.typedef)'% (exc_name, )) @@ -597,7 +608,7 @@ 'PyCFunction_Type': 'space.gettypeobject(cpyext.methodobject.W_PyCFunctionObject.typedef)', 'PyWrapperDescr_Type': 'space.gettypeobject(cpyext.methodobject.W_PyCMethodObject.typedef)' }.items(): -GLOBALS['%s#%s' % (cpyname, pypy_decl)] = ('PyTypeObject*', pypyexpr) +register_global(cpyname, 'PyTypeObject*', pypyexpr, header=pypy_decl) for cpyname in '''PyMethodObject PyListObject PyLongObject PyClassObject'''.split(): @@ -1403,10 +1414,12 @@ return use_micronumpy # import registers api functions by side-effect, we also need HEADER from pypy.module.cpyext.ndarrayobject import HEADER -global GLOBALS, FUNCTIONS_BY_HEADER, separate_module_files +global FUNCTIONS_BY_HEADER, separate_module_files for func_name in ['PyArray_Type', '_PyArray_FILLWBYTE', '_PyArray_ZEROS']: FUNCTIONS_BY_HEADER.setdefault(HEADER, {})[func_name] = None -GLOBALS["PyArray_Type#%s" % HEADER] = ('PyTypeObject*', "space.gettypeobject(W_NDimArray.typedef)") +register_global("PyArray_Type", +'PyTypeObject*', "space.gettypeobject(W_NDimArray.typedef)", +header=HEADER) separate_module_files.append(source_dir / "ndarrayobject.c") return use_micronumpy ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] pypy default: Delete obsolete and undocumented file
Author: Ronan Lamy Branch: Changeset: r89270:6e6b17b429d7 Date: 2016-12-29 20:57 +0100 http://bitbucket.org/pypy/pypy/changeset/6e6b17b429d7/ Log:Delete obsolete and undocumented file diff --git a/pypy/module/cpyext/stubgen.py b/pypy/module/cpyext/stubgen.py deleted file mode 100644 --- a/pypy/module/cpyext/stubgen.py +++ /dev/null @@ -1,100 +0,0 @@ -# -*- coding: utf-8 -*- -from os import path - -from pypy.module.cpyext import api - -from sphinx import addnodes - - -TEMPLATE = """ -@cpython_api([%(paramtypes)s], %(rettype)s) -def %(functionname)s(%(params)s): -%(docstring)sraise NotImplementedError -%(borrows)s -""" - -C_TYPE_TO_PYPY_TYPE = { -"void": "lltype.Void", -"int": "rffi.INT_real", -"PyTypeObject*": "PyTypeObjectPtr", -"PyVarObject*": "PyObject", -"const char*": "rffi.CCHARP", -"double": "rffi.DOUBLE", -"PyObject*": "PyObject", -"PyObject**": "PyObjectP", -"char*": "rffi.CCHARP", -"PyMethodDef*": "PyMethodDef", -"Py_ssize_t": "Py_ssize_t", -"Py_ssize_t*": "Py_ssize_t", -"size_t": "rffi.SIZE_T", -"...": "...", -"char": "lltype.Char", -"long": "lltype.Signed", -"Py_buffer*": "Py_buffer", -"": "", -} - -C_TYPE_TO_PYPY_TYPE_ARGS = C_TYPE_TO_PYPY_TYPE.copy() -C_TYPE_TO_PYPY_TYPE_ARGS.update({ -"void": "rffi.VOIDP", -}) - - -def c_param_to_type_and_name(string, is_arg=True): -string = string.replace(" **", "** ").replace(" *", "* ") -try: -typ, name = string.rsplit(" ", 1) -except ValueError: -typ = string -name = "" -return [C_TYPE_TO_PYPY_TYPE, C_TYPE_TO_PYPY_TYPE_ARGS][is_arg]\ -.get(typ, "{" + typ + "}"), name - - -def process_doctree(app, doctree): -for node in doctree.traverse(addnodes.desc_content): -par = node.parent -if par['desctype'] != 'cfunction': -continue -if not par[0].has_key('names') or not par[0]['names']: -continue -functionname = par[0]['names'][0] -if (functionname in api.FUNCTIONS or -functionname in api.SYMBOLS_C): -print "Wow, you implemented already", functionname -continue -borrows = docstring = "" -crettype, _, cparameters = par[0] -crettype = crettype.astext() -cparameters = cparameters.astext() -rettype, _ = c_param_to_type_and_name(crettype, False) -params = ["space"] -paramtypes = [] -for param in cparameters.split(","): -typ, name = c_param_to_type_and_name(param.strip()) -params.append(name) -paramtypes.append(typ) -params = ", ".join(params) -paramtypes = ", ".join(paramtypes) -docstring = node.astext() -entry = app._refcounts.get(functionname) -if entry and entry.result_type in ("PyObject*", "PyVarObject*"): -if entry.result_refs is None: -docstring += "\nReturn value: always NULL." -else: -borrows = ("borrow_from()", "")[entry.result_refs] -docstring = "\n".join(docstring.splitlines()) -if docstring: -docstring = '"""%s"""\n' % (docstring,) -code = TEMPLATE % locals() -app._stubgen_f.write(code) - - -def init_apidump(app): -fname = path.join(path.dirname(api.__file__), "stubs.py") -app._stubgen_f = file(fname, "w") -app.connect('doctree-read', process_doctree) - - -def setup(app): -app.connect('builder-inited', init_apidump) ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit
[pypy-commit] cffi default: We're interested in --with-pydebug not -d
Author: Stefano Rivera Branch: Changeset: r2844:bd6789d993c6 Date: 2016-12-30 00:05 +0100 http://bitbucket.org/cffi/cffi/changeset/bd6789d993c6/ Log:We're interested in --with-pydebug not -d diff --git a/cffi/setuptools_ext.py b/cffi/setuptools_ext.py --- a/cffi/setuptools_ext.py +++ b/cffi/setuptools_ext.py @@ -79,9 +79,10 @@ CPython itself should ignore the flag in a debugging version (by not listing .abi3.so in the extensions it supports), but it doesn't so far, creating troubles. That's why we check -for "not sys.flags.debug". (http://bugs.python.org/issue28401) +for "not hasattr(sys, 'gettotalrefcount')" (the 2.7 compatible equivalent +of 'd' not in sys.abiflags). (http://bugs.python.org/issue28401) """ -if 'py_limited_api' not in kwds and not sys.flags.debug: +if 'py_limited_api' not in kwds and not hasattr(sys, 'gettotalrefcount'): import setuptools try: setuptools_major_version = int(setuptools.__version__.partition('.')[0]) diff --git a/testing/cffi0/test_zintegration.py b/testing/cffi0/test_zintegration.py --- a/testing/cffi0/test_zintegration.py +++ b/testing/cffi0/test_zintegration.py @@ -156,20 +156,21 @@ except ImportError as e: py.test.skip(str(e)) orig_version = setuptools.__version__ +expecting_limited_api = not hasattr(sys, 'gettotalrefcount') try: setuptools.__version__ = '26.0.0' from setuptools import Extension kwds = _set_py_limited_api(Extension, {}) -assert kwds['py_limited_api'] == True +assert kwds.get('py_limited_api', False) == expecting_limited_api setuptools.__version__ = '25.0' kwds = _set_py_limited_api(Extension, {}) -assert not kwds +assert kwds.get('py_limited_api', False) == False setuptools.__version__ = 'development' kwds = _set_py_limited_api(Extension, {}) -assert kwds['py_limited_api'] == True +assert kwds.get('py_limited_api', False) == expecting_limited_api finally: setuptools.__version__ = orig_version ___ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit