[pypy-commit] pypy improve-docs: hg merge default
Manuel Jacob
noreply at buildbot.pypy.org
Tue Jun 11 16:06:16 CEST 2013
Author: Manuel Jacob
Branch: improve-docs
Changeset: r64857:0da9b23be0af
Date: 2013-06-11 16:04 +0200
http://bitbucket.org/pypy/pypy/changeset/0da9b23be0af/
Log: hg merge default
diff too long, truncating to 2000 out of 25881 lines
diff --git a/lib-python/2.7/distutils/command/build_ext.py b/lib-python/2.7/distutils/command/build_ext.py
--- a/lib-python/2.7/distutils/command/build_ext.py
+++ b/lib-python/2.7/distutils/command/build_ext.py
@@ -8,7 +8,7 @@
__revision__ = "$Id$"
-import sys, os, string, re
+import sys, os, string, re, imp
from types import *
from site import USER_BASE, USER_SITE
from distutils.core import Command
@@ -33,6 +33,11 @@
from distutils.ccompiler import show_compilers
show_compilers()
+def _get_c_extension_suffix():
+ for ext, mod, typ in imp.get_suffixes():
+ if typ == imp.C_EXTENSION:
+ return ext
+
class build_ext (Command):
@@ -677,10 +682,18 @@
# OS/2 has an 8 character module (extension) limit :-(
if os.name == "os2":
ext_path[len(ext_path) - 1] = ext_path[len(ext_path) - 1][:8]
+ # PyPy tweak: first try to get the C extension suffix from
+ # 'imp'. If it fails we fall back to the 'SO' config var, like
+ # the previous version of this code did. This should work for
+ # CPython too. The point is that on PyPy with cpyext, the
+ # config var 'SO' is just ".so" but we want to return
+ # ".pypy-VERSION.so" instead.
+ so_ext = _get_c_extension_suffix()
+ if so_ext is None:
+ so_ext = get_config_var('SO') # fall-back
# extensions in debug_mode are named 'module_d.pyd' under windows
- so_ext = get_config_var('SO')
if os.name == 'nt' and self.debug:
- return os.path.join(*ext_path) + '_d' + so_ext
+ so_ext = '_d.pyd'
return os.path.join(*ext_path) + so_ext
def get_export_symbols (self, ext):
diff --git a/lib-python/2.7/distutils/sysconfig.py b/lib-python/2.7/distutils/sysconfig.py
--- a/lib-python/2.7/distutils/sysconfig.py
+++ b/lib-python/2.7/distutils/sysconfig.py
@@ -1,30 +1,16 @@
-"""Provide access to Python's configuration information. The specific
-configuration variables available depend heavily on the platform and
-configuration. The values may be retrieved using
-get_config_var(name), and the list of variables is available via
-get_config_vars().keys(). Additional convenience functions are also
-available.
-
-Written by: Fred L. Drake, Jr.
-Email: <fdrake at acm.org>
-"""
-
-__revision__ = "$Id: sysconfig.py 85358 2010-10-10 09:54:59Z antoine.pitrou $"
-
-import sys
-
# The content of this file is redirected from
# sysconfig_cpython or sysconfig_pypy.
+# All underscore names are imported too, because
+# people like to use undocumented sysconfig._xxx
+# directly.
+import sys
if '__pypy__' in sys.builtin_module_names:
- from distutils.sysconfig_pypy import *
- from distutils.sysconfig_pypy import _config_vars # needed by setuptools
- from distutils.sysconfig_pypy import _variable_rx # read_setup_file()
+ from distutils import sysconfig_pypy as _sysconfig_module
else:
- from distutils.sysconfig_cpython import *
- from distutils.sysconfig_cpython import _config_vars # needed by setuptools
- from distutils.sysconfig_cpython import _variable_rx # read_setup_file()
+ from distutils import sysconfig_cpython as _sysconfig_module
+globals().update(_sysconfig_module.__dict__)
_USE_CLANG = None
diff --git a/lib-python/2.7/distutils/sysconfig_cpython.py b/lib-python/2.7/distutils/sysconfig_cpython.py
--- a/lib-python/2.7/distutils/sysconfig_cpython.py
+++ b/lib-python/2.7/distutils/sysconfig_cpython.py
@@ -9,7 +9,7 @@
Email: <fdrake at acm.org>
"""
-__revision__ = "$Id$"
+__revision__ = "$Id: sysconfig.py 85358 2010-10-10 09:54:59Z antoine.pitrou $"
import os
import re
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
@@ -1,9 +1,17 @@
-"""PyPy's minimal configuration information.
+"""Provide access to Python's configuration information.
+This is actually PyPy's minimal configuration information.
+
+The specific configuration variables available depend heavily on the
+platform and configuration. The values may be retrieved using
+get_config_var(name), and the list of variables is available via
+get_config_vars().keys(). Additional convenience functions are also
+available.
"""
+__revision__ = "$Id: sysconfig.py 85358 2010-10-10 09:54:59Z antoine.pitrou $"
+
import sys
import os
-import imp
from distutils.errors import DistutilsPlatformError
@@ -49,16 +57,11 @@
_config_vars = None
-def _get_so_extension():
- for ext, mod, typ in imp.get_suffixes():
- if typ == imp.C_EXTENSION:
- return ext
-
def _init_posix():
"""Initialize the module as appropriate for POSIX systems."""
g = {}
g['EXE'] = ""
- g['SO'] = _get_so_extension() or ".so"
+ g['SO'] = ".so"
g['SOABI'] = g['SO'].rsplit('.')[0]
g['LIBDIR'] = os.path.join(sys.prefix, 'lib')
g['CC'] = "gcc -pthread" # -pthread might not be valid on OS/X, check
@@ -71,7 +74,7 @@
"""Initialize the module as appropriate for NT"""
g = {}
g['EXE'] = ".exe"
- g['SO'] = _get_so_extension() or ".pyd"
+ g['SO'] = ".pyd"
g['SOABI'] = g['SO'].rsplit('.')[0]
global _config_vars
diff --git a/lib-python/2.7/logging/__init__.py b/lib-python/2.7/logging/__init__.py
--- a/lib-python/2.7/logging/__init__.py
+++ b/lib-python/2.7/logging/__init__.py
@@ -134,21 +134,25 @@
DEBUG = 10
NOTSET = 0
-_levelNames = {
- CRITICAL : 'CRITICAL',
- ERROR : 'ERROR',
- WARNING : 'WARNING',
- INFO : 'INFO',
- DEBUG : 'DEBUG',
- NOTSET : 'NOTSET',
- 'CRITICAL' : CRITICAL,
- 'ERROR' : ERROR,
- 'WARN' : WARNING,
- 'WARNING' : WARNING,
- 'INFO' : INFO,
- 'DEBUG' : DEBUG,
- 'NOTSET' : NOTSET,
+_levelToName = {
+ CRITICAL: 'CRITICAL',
+ ERROR: 'ERROR',
+ WARNING: 'WARNING',
+ INFO: 'INFO',
+ DEBUG: 'DEBUG',
+ NOTSET: 'NOTSET',
}
+_nameToLevel = {
+ 'CRITICAL': CRITICAL,
+ 'ERROR': ERROR,
+ 'WARN': WARNING,
+ 'WARNING': WARNING,
+ 'INFO': INFO,
+ 'DEBUG': DEBUG,
+ 'NOTSET': NOTSET,
+}
+_levelNames = dict(_levelToName)
+_levelNames.update(_nameToLevel) # backward compatibility
def getLevelName(level):
"""
@@ -164,7 +168,7 @@
Otherwise, the string "Level %s" % level is returned.
"""
- return _levelNames.get(level, ("Level %s" % level))
+ return _levelToName.get(level, ("Level %s" % level))
def addLevelName(level, levelName):
"""
@@ -174,8 +178,8 @@
"""
_acquireLock()
try: #unlikely to cause an exception, but you never know...
- _levelNames[level] = levelName
- _levelNames[levelName] = level
+ _levelToName[level] = levelName
+ _nameToLevel[levelName] = level
finally:
_releaseLock()
@@ -183,9 +187,9 @@
if isinstance(level, int):
rv = level
elif str(level) == level:
- if level not in _levelNames:
+ if level not in _nameToLevel:
raise ValueError("Unknown level: %r" % level)
- rv = _levelNames[level]
+ rv = _nameToLevel[level]
else:
raise TypeError("Level not an integer or a valid string: %r" % level)
return rv
@@ -277,7 +281,7 @@
self.lineno = lineno
self.funcName = func
self.created = ct
- self.msecs = (ct - long(ct)) * 1000
+ self.msecs = (ct - int(ct)) * 1000
self.relativeCreated = (self.created - _startTime) * 1000
if logThreads and thread:
self.thread = thread.get_ident()
diff --git a/lib-python/2.7/logging/config.py b/lib-python/2.7/logging/config.py
--- a/lib-python/2.7/logging/config.py
+++ b/lib-python/2.7/logging/config.py
@@ -156,7 +156,7 @@
h = klass(*args)
if "level" in opts:
level = cp.get(sectname, "level")
- h.setLevel(logging._levelNames[level])
+ h.setLevel(level)
if len(fmt):
h.setFormatter(formatters[fmt])
if issubclass(klass, logging.handlers.MemoryHandler):
@@ -187,7 +187,7 @@
opts = cp.options(sectname)
if "level" in opts:
level = cp.get(sectname, "level")
- log.setLevel(logging._levelNames[level])
+ log.setLevel(level)
for h in root.handlers[:]:
root.removeHandler(h)
hlist = cp.get(sectname, "handlers")
@@ -237,7 +237,7 @@
existing.remove(qn)
if "level" in opts:
level = cp.get(sectname, "level")
- logger.setLevel(logging._levelNames[level])
+ logger.setLevel(level)
for h in logger.handlers[:]:
logger.removeHandler(h)
logger.propagate = propagate
diff --git a/lib-python/2.7/opcode.py b/lib-python/2.7/opcode.py
--- a/lib-python/2.7/opcode.py
+++ b/lib-python/2.7/opcode.py
@@ -193,5 +193,6 @@
hasname.append(201)
def_op('CALL_METHOD', 202) # #args not including 'self'
def_op('BUILD_LIST_FROM_ARG', 203)
+jrel_op('JUMP_IF_NOT_DEBUG', 204) # jump over assert statements
del def_op, name_op, jrel_op, jabs_op
diff --git a/lib-python/2.7/socket.py b/lib-python/2.7/socket.py
--- a/lib-python/2.7/socket.py
+++ b/lib-python/2.7/socket.py
@@ -96,6 +96,7 @@
_realsocket = socket
+_type = type
# WSA error codes
if sys.platform.lower().startswith("win"):
@@ -173,31 +174,37 @@
__doc__ = _realsocket.__doc__
+ __slots__ = ["_sock", "__weakref__"]
+
def __init__(self, family=AF_INET, type=SOCK_STREAM, proto=0, _sock=None):
if _sock is None:
_sock = _realsocket(family, type, proto)
+ elif _type(_sock) is _realsocket:
+ _sock._reuse()
+ # PyPy note about refcounting: implemented with _reuse()/_drop()
+ # on the class '_socket.socket'. Python 3 did it differently
+ # with a reference counter on this class 'socket._socketobject'
+ # instead, but it is a less compatible change (breaks eventlet).
self._sock = _sock
- self._io_refs = 0
- self._closed = False
def send(self, data, flags=0):
- return self._sock.send(data, flags=flags)
+ return self._sock.send(data, flags)
send.__doc__ = _realsocket.send.__doc__
def recv(self, buffersize, flags=0):
- return self._sock.recv(buffersize, flags=flags)
+ return self._sock.recv(buffersize, flags)
recv.__doc__ = _realsocket.recv.__doc__
def recv_into(self, buffer, nbytes=0, flags=0):
- return self._sock.recv_into(buffer, nbytes=nbytes, flags=flags)
+ return self._sock.recv_into(buffer, nbytes, flags)
recv_into.__doc__ = _realsocket.recv_into.__doc__
def recvfrom(self, buffersize, flags=0):
- return self._sock.recvfrom(buffersize, flags=flags)
+ return self._sock.recvfrom(buffersize, flags)
recvfrom.__doc__ = _realsocket.recvfrom.__doc__
def recvfrom_into(self, buffer, nbytes=0, flags=0):
- return self._sock.recvfrom_into(buffer, nbytes=nbytes, flags=flags)
+ return self._sock.recvfrom_into(buffer, nbytes, flags)
recvfrom_into.__doc__ = _realsocket.recvfrom_into.__doc__
def sendto(self, data, param2, param3=None):
@@ -208,13 +215,17 @@
sendto.__doc__ = _realsocket.sendto.__doc__
def close(self):
- # This function should not reference any globals. See issue #808164.
+ s = self._sock
+ if type(s) is _realsocket:
+ s._drop()
self._sock = _closedsocket()
close.__doc__ = _realsocket.close.__doc__
def accept(self):
sock, addr = self._sock.accept()
- return _socketobject(_sock=sock), addr
+ sockobj = _socketobject(_sock=sock)
+ sock._drop() # already a copy in the _socketobject()
+ return sockobj, addr
accept.__doc__ = _realsocket.accept.__doc__
def dup(self):
@@ -228,24 +239,7 @@
Return a regular file object corresponding to the socket. The mode
and bufsize arguments are as for the built-in open() function."""
- self._io_refs += 1
- return _fileobject(self, mode, bufsize)
-
- def _decref_socketios(self):
- if self._io_refs > 0:
- self._io_refs -= 1
- if self._closed:
- self.close()
-
- def _real_close(self):
- # This function should not reference any globals. See issue #808164.
- self._sock.close()
-
- def close(self):
- # This function should not reference any globals. See issue #808164.
- self._closed = True
- if self._io_refs <= 0:
- self._real_close()
+ return _fileobject(self._sock, mode, bufsize)
family = property(lambda self: self._sock.family, doc="the socket family")
type = property(lambda self: self._sock.type, doc="the socket type")
@@ -286,6 +280,8 @@
"_close"]
def __init__(self, sock, mode='rb', bufsize=-1, close=False):
+ if type(sock) is _realsocket:
+ sock._reuse()
self._sock = sock
self.mode = mode # Not actually used in this version
if bufsize < 0:
@@ -320,11 +316,11 @@
if self._sock:
self.flush()
finally:
- if self._sock:
- if self._close:
- self._sock.close()
- else:
- self._sock._decref_socketios()
+ s = self._sock
+ if type(s) is _realsocket:
+ s._drop()
+ if self._close:
+ self._sock.close()
self._sock = None
def __del__(self):
diff --git a/lib-python/2.7/test/test_code.py b/lib-python/2.7/test/test_code.py
--- a/lib-python/2.7/test/test_code.py
+++ b/lib-python/2.7/test/test_code.py
@@ -75,7 +75,7 @@
cellvars: ()
freevars: ()
nlocals: 0
-flags: 67
+flags: 1048643
consts: ("'doc string'", 'None')
"""
diff --git a/lib-python/2.7/test/test_codecs.py b/lib-python/2.7/test/test_codecs.py
--- a/lib-python/2.7/test/test_codecs.py
+++ b/lib-python/2.7/test/test_codecs.py
@@ -2,7 +2,11 @@
import unittest
import codecs
import locale
-import sys, StringIO, _testcapi
+import sys, StringIO
+try:
+ import _testcapi
+except ImportError:
+ _testcapi = None
class Queue(object):
"""
@@ -1387,7 +1391,7 @@
decodedresult += reader.read()
self.assertEqual(decodedresult, s, "%r != %r (encoding=%r)" % (decodedresult, s, encoding))
- if encoding not in broken_incremental_coders:
+ if encoding not in broken_incremental_coders and _testcapi:
# check incremental decoder/encoder (fetched via the Python
# and C API) and iterencode()/iterdecode()
try:
diff --git a/lib-python/2.7/test/test_dis.py b/lib-python/2.7/test/test_dis.py
--- a/lib-python/2.7/test/test_dis.py
+++ b/lib-python/2.7/test/test_dis.py
@@ -53,25 +53,26 @@
pass
dis_bug1333982 = """\
- %-4d 0 LOAD_CONST 1 (0)
- 3 POP_JUMP_IF_TRUE 41
- 6 LOAD_GLOBAL 0 (AssertionError)
- 9 LOAD_FAST 0 (x)
- 12 BUILD_LIST_FROM_ARG 0
- 15 GET_ITER
- >> 16 FOR_ITER 12 (to 31)
- 19 STORE_FAST 1 (s)
- 22 LOAD_FAST 1 (s)
- 25 LIST_APPEND 2
- 28 JUMP_ABSOLUTE 16
+ %-4d 0 JUMP_IF_NOT_DEBUG 41 (to 44)
+ 3 LOAD_CONST 1 (0)
+ 6 POP_JUMP_IF_TRUE 44
+ 9 LOAD_GLOBAL 0 (AssertionError)
+ 12 LOAD_FAST 0 (x)
+ 15 BUILD_LIST_FROM_ARG 0
+ 18 GET_ITER
+ >> 19 FOR_ITER 12 (to 34)
+ 22 STORE_FAST 1 (s)
+ 25 LOAD_FAST 1 (s)
+ 28 LIST_APPEND 2
+ 31 JUMP_ABSOLUTE 19
- %-4d >> 31 LOAD_CONST 2 (1)
- 34 BINARY_ADD
- 35 CALL_FUNCTION 1
- 38 RAISE_VARARGS 1
+ %-4d >> 34 LOAD_CONST 2 (1)
+ 37 BINARY_ADD
+ 38 CALL_FUNCTION 1
+ 41 RAISE_VARARGS 1
- %-4d >> 41 LOAD_CONST 0 (None)
- 44 RETURN_VALUE
+ %-4d >> 44 LOAD_CONST 0 (None)
+ 47 RETURN_VALUE
"""%(bug1333982.func_code.co_firstlineno + 1,
bug1333982.func_code.co_firstlineno + 2,
bug1333982.func_code.co_firstlineno + 3)
diff --git a/lib-python/2.7/test/test_logging.py b/lib-python/2.7/test/test_logging.py
--- a/lib-python/2.7/test/test_logging.py
+++ b/lib-python/2.7/test/test_logging.py
@@ -65,7 +65,8 @@
self.saved_handlers = logging._handlers.copy()
self.saved_handler_list = logging._handlerList[:]
self.saved_loggers = logger_dict.copy()
- self.saved_level_names = logging._levelNames.copy()
+ self.saved_name_to_level = logging._nameToLevel.copy()
+ self.saved_level_to_name = logging._levelToName.copy()
finally:
logging._releaseLock()
@@ -97,8 +98,10 @@
self.root_logger.setLevel(self.original_logging_level)
logging._acquireLock()
try:
- logging._levelNames.clear()
- logging._levelNames.update(self.saved_level_names)
+ logging._levelToName.clear()
+ logging._levelToName.update(self.saved_level_to_name)
+ logging._nameToLevel.clear()
+ logging._nameToLevel.update(self.saved_name_to_level)
logging._handlers.clear()
logging._handlers.update(self.saved_handlers)
logging._handlerList[:] = self.saved_handler_list
diff --git a/lib-python/2.7/test/test_sysconfig.py b/lib-python/2.7/test/test_sysconfig.py
--- a/lib-python/2.7/test/test_sysconfig.py
+++ b/lib-python/2.7/test/test_sysconfig.py
@@ -7,7 +7,8 @@
import subprocess
from copy import copy, deepcopy
-from test.test_support import run_unittest, TESTFN, unlink, get_attribute
+from test.test_support import (run_unittest, TESTFN, unlink, get_attribute,
+ import_module)
import sysconfig
from sysconfig import (get_paths, get_platform, get_config_vars,
@@ -236,7 +237,10 @@
def test_get_config_h_filename(self):
config_h = sysconfig.get_config_h_filename()
- self.assertTrue(os.path.isfile(config_h), config_h)
+ # import_module skips the test when the CPython C Extension API
+ # appears to not be supported
+ self.assertTrue(os.path.isfile(config_h) or
+ not import_module('_testcapi'), config_h)
def test_get_scheme_names(self):
wanted = ('nt', 'nt_user', 'os2', 'os2_home', 'osx_framework_user',
diff --git a/lib-python/2.7/test/test_traceback.py b/lib-python/2.7/test/test_traceback.py
--- a/lib-python/2.7/test/test_traceback.py
+++ b/lib-python/2.7/test/test_traceback.py
@@ -1,6 +1,9 @@
"""Test cases for traceback module"""
-from _testcapi import traceback_print
+try:
+ from _testcapi import traceback_print
+except ImportError:
+ traceback_print = None
from StringIO import StringIO
import sys
import unittest
@@ -176,6 +179,8 @@
class TracebackFormatTests(unittest.TestCase):
def test_traceback_format(self):
+ if traceback_print is None:
+ raise unittest.SkipTest('Requires _testcapi')
try:
raise KeyError('blah')
except KeyError:
diff --git a/lib-python/2.7/test/test_unicode.py b/lib-python/2.7/test/test_unicode.py
--- a/lib-python/2.7/test/test_unicode.py
+++ b/lib-python/2.7/test/test_unicode.py
@@ -1609,7 +1609,10 @@
self.assertEqual("{}".format(u), '__unicode__ overridden')
def test_encode_decimal(self):
- from _testcapi import unicode_encodedecimal
+ try:
+ from _testcapi import unicode_encodedecimal
+ except ImportError:
+ raise unittest.SkipTest('Requires _testcapi')
self.assertEqual(unicode_encodedecimal(u'123'),
b'123')
self.assertEqual(unicode_encodedecimal(u'\u0663.\u0661\u0664'),
diff --git a/lib-python/conftest.py b/lib-python/conftest.py
--- a/lib-python/conftest.py
+++ b/lib-python/conftest.py
@@ -130,7 +130,7 @@
RegrTest('test_bz2.py', usemodules='bz2'),
RegrTest('test_calendar.py'),
RegrTest('test_call.py', core=True),
- RegrTest('test_capi.py'),
+ RegrTest('test_capi.py', usemodules='cpyext'),
RegrTest('test_cd.py'),
RegrTest('test_cfgparser.py'),
RegrTest('test_cgi.py'),
@@ -177,7 +177,7 @@
RegrTest('test_cprofile.py'),
RegrTest('test_crypt.py', usemodules='crypt'),
RegrTest('test_csv.py', usemodules='_csv'),
- RegrTest('test_ctypes.py', usemodules="_rawffi thread"),
+ RegrTest('test_ctypes.py', usemodules="_rawffi thread cpyext"),
RegrTest('test_curses.py'),
RegrTest('test_datetime.py', usemodules='binascii struct'),
RegrTest('test_dbm.py'),
diff --git a/lib_pypy/_ctypes/pointer.py b/lib_pypy/_ctypes/pointer.py
--- a/lib_pypy/_ctypes/pointer.py
+++ b/lib_pypy/_ctypes/pointer.py
@@ -120,6 +120,7 @@
return self._buffer[0] != 0
contents = property(getcontents, setcontents)
+ _obj = property(getcontents) # byref interface
def _as_ffi_pointer_(self, ffitype):
return as_ffi_pointer(self, ffitype)
diff --git a/lib_pypy/_ctypes/structure.py b/lib_pypy/_ctypes/structure.py
--- a/lib_pypy/_ctypes/structure.py
+++ b/lib_pypy/_ctypes/structure.py
@@ -166,8 +166,7 @@
if self is StructOrUnion:
return
if '_fields_' not in self.__dict__:
- self._fields_ = []
- _set_shape(self, [], self._is_union)
+ self._fields_ = [] # As a side-effet, this also sets the ffishape.
__setattr__ = struct_setattr
diff --git a/lib_pypy/_ctypes_test.py b/lib_pypy/_ctypes_test.py
--- a/lib_pypy/_ctypes_test.py
+++ b/lib_pypy/_ctypes_test.py
@@ -1,60 +1,7 @@
-import os, sys
-import tempfile
-
-def compile_shared():
- """Compile '_ctypes_test.c' into an extension module, and import it
- """
- thisdir = os.path.dirname(__file__)
- output_dir = tempfile.mkdtemp()
-
- from distutils.ccompiler import new_compiler
- from distutils import sysconfig
-
- compiler = new_compiler()
- compiler.output_dir = output_dir
-
- # Compile .c file
- include_dir = os.path.join(thisdir, '..', 'include')
- if sys.platform == 'win32':
- ccflags = ['-D_CRT_SECURE_NO_WARNINGS']
- else:
- ccflags = ['-fPIC', '-Wimplicit-function-declaration']
- res = compiler.compile([os.path.join(thisdir, '_ctypes_test.c')],
- include_dirs=[include_dir],
- extra_preargs=ccflags)
- object_filename = res[0]
-
- # set link options
- output_filename = '_ctypes_test' + sysconfig.get_config_var('SO')
- if sys.platform == 'win32':
- # XXX libpypy-c.lib is currently not installed automatically
- library = os.path.join(thisdir, '..', 'include', 'libpypy-c')
- if not os.path.exists(library + '.lib'):
- #For a nightly build
- library = os.path.join(thisdir, '..', 'include', 'python27')
- if not os.path.exists(library + '.lib'):
- # For a local translation
- library = os.path.join(thisdir, '..', 'pypy', 'goal', 'libpypy-c')
- libraries = [library, 'oleaut32']
- extra_ldargs = ['/MANIFEST', # needed for VC10
- '/EXPORT:init_ctypes_test']
- else:
- libraries = []
- extra_ldargs = []
-
- # link the dynamic library
- compiler.link_shared_object(
- [object_filename],
- output_filename,
- libraries=libraries,
- extra_preargs=extra_ldargs)
-
- # Now import the newly created library, it will replace our module in sys.modules
- import imp
- fp, filename, description = imp.find_module('_ctypes_test', path=[output_dir])
- imp.load_module('_ctypes_test', fp, filename, description)
-
-
+try:
+ import cpyext
+except ImportError:
+ raise ImportError("No module named '_ctypes_test'")
try:
import _ctypes
_ctypes.PyObj_FromPtr = None
@@ -62,4 +9,5 @@
except ImportError:
pass # obscure condition of _ctypes_test.py being imported by py.test
else:
- compile_shared()
+ import _pypy_testcapi
+ _pypy_testcapi.compile_shared('_ctypes_test.c', '_ctypes_test')
diff --git a/lib_pypy/_pypy_irc_topic.py b/lib_pypy/_pypy_irc_topic.py
--- a/lib_pypy/_pypy_irc_topic.py
+++ b/lib_pypy/_pypy_irc_topic.py
@@ -1,4 +1,4 @@
-"""eclguba: flagnk naq frznagvpf bs clguba, fcrrq bs p, erfgevpgvbaf bs wnin naq pbzcvyre reebe zrffntrf nf crargenoyr nf ZHZCF
+__doc__ = """eclguba: flagnk naq frznagvpf bs clguba, fcrrq bs p, erfgevpgvbaf bs wnin naq pbzcvyre reebe zrffntrf nf crargenoyr nf ZHZCF
pglcrf unf n fcva bs 1/3
' ' vf n fcnpr gbb
Clguba 2.k rfg cerfdhr zbeg, ivir Clguba!
diff --git a/lib_pypy/_testcapi.py b/lib_pypy/_pypy_testcapi.py
copy from lib_pypy/_testcapi.py
copy to lib_pypy/_pypy_testcapi.py
--- a/lib_pypy/_testcapi.py
+++ b/lib_pypy/_pypy_testcapi.py
@@ -1,14 +1,20 @@
-import os, sys
+import os, sys, imp
import tempfile
-def compile_shared():
- """Compile '_testcapi.c' into an extension module, and import it
+def _get_c_extension_suffix():
+ for ext, mod, typ in imp.get_suffixes():
+ if typ == imp.C_EXTENSION:
+ return ext
+
+
+def compile_shared(csource, modulename):
+ """Compile '_testcapi.c' or '_ctypes_test.c' into an extension module,
+ and import it.
"""
thisdir = os.path.dirname(__file__)
output_dir = tempfile.mkdtemp()
from distutils.ccompiler import new_compiler
- from distutils import sysconfig
compiler = new_compiler()
compiler.output_dir = output_dir
@@ -19,13 +25,13 @@
ccflags = ['-D_CRT_SECURE_NO_WARNINGS']
else:
ccflags = ['-fPIC', '-Wimplicit-function-declaration']
- res = compiler.compile([os.path.join(thisdir, '_testcapimodule.c')],
+ res = compiler.compile([os.path.join(thisdir, csource)],
include_dirs=[include_dir],
extra_preargs=ccflags)
object_filename = res[0]
# set link options
- output_filename = '_testcapi' + sysconfig.get_config_var('SO')
+ output_filename = modulename + _get_c_extension_suffix()
if sys.platform == 'win32':
# XXX libpypy-c.lib is currently not installed automatically
library = os.path.join(thisdir, '..', 'include', 'libpypy-c')
@@ -37,7 +43,7 @@
library = os.path.join(thisdir, '..', 'pypy', 'goal', 'libpypy-c')
libraries = [library, 'oleaut32']
extra_ldargs = ['/MANIFEST', # needed for VC10
- '/EXPORT:init_testcapi']
+ '/EXPORT:init' + modulename]
else:
libraries = []
extra_ldargs = []
@@ -49,9 +55,7 @@
libraries=libraries,
extra_preargs=extra_ldargs)
- # Now import the newly created library, it will replace our module in sys.modules
- import imp
- fp, filename, description = imp.find_module('_testcapi', path=[output_dir])
- imp.load_module('_testcapi', fp, filename, description)
-
-compile_shared()
+ # Now import the newly created library, it will replace the original
+ # module in sys.modules
+ fp, filename, description = imp.find_module(modulename, path=[output_dir])
+ imp.load_module(modulename, fp, filename, description)
diff --git a/lib_pypy/_testcapi.py b/lib_pypy/_testcapi.py
--- a/lib_pypy/_testcapi.py
+++ b/lib_pypy/_testcapi.py
@@ -1,57 +1,7 @@
-import os, sys
-import tempfile
-
-def compile_shared():
- """Compile '_testcapi.c' into an extension module, and import it
- """
- thisdir = os.path.dirname(__file__)
- output_dir = tempfile.mkdtemp()
-
- from distutils.ccompiler import new_compiler
- from distutils import sysconfig
-
- compiler = new_compiler()
- compiler.output_dir = output_dir
-
- # Compile .c file
- include_dir = os.path.join(thisdir, '..', 'include')
- if sys.platform == 'win32':
- ccflags = ['-D_CRT_SECURE_NO_WARNINGS']
- else:
- ccflags = ['-fPIC', '-Wimplicit-function-declaration']
- res = compiler.compile([os.path.join(thisdir, '_testcapimodule.c')],
- include_dirs=[include_dir],
- extra_preargs=ccflags)
- object_filename = res[0]
-
- # set link options
- output_filename = '_testcapi' + sysconfig.get_config_var('SO')
- if sys.platform == 'win32':
- # XXX libpypy-c.lib is currently not installed automatically
- library = os.path.join(thisdir, '..', 'include', 'libpypy-c')
- if not os.path.exists(library + '.lib'):
- #For a nightly build
- library = os.path.join(thisdir, '..', 'include', 'python27')
- if not os.path.exists(library + '.lib'):
- # For a local translation
- library = os.path.join(thisdir, '..', 'pypy', 'goal', 'libpypy-c')
- libraries = [library, 'oleaut32']
- extra_ldargs = ['/MANIFEST', # needed for VC10
- '/EXPORT:init_testcapi']
- else:
- libraries = []
- extra_ldargs = []
-
- # link the dynamic library
- compiler.link_shared_object(
- [object_filename],
- output_filename,
- libraries=libraries,
- extra_preargs=extra_ldargs)
-
- # Now import the newly created library, it will replace our module in sys.modules
- import imp
- fp, filename, description = imp.find_module('_testcapi', path=[output_dir])
- imp.load_module('_testcapi', fp, filename, description)
-
-compile_shared()
+try:
+ import cpyext
+except ImportError:
+ raise ImportError("No module named '_testcapi'")
+else:
+ import _pypy_testcapi
+ _pypy_testcapi.compile_shared('_testcapimodule.c', '_testcapi')
diff --git a/lib_pypy/cffi/__init__.py b/lib_pypy/cffi/__init__.py
--- a/lib_pypy/cffi/__init__.py
+++ b/lib_pypy/cffi/__init__.py
@@ -4,5 +4,5 @@
from .api import FFI, CDefError, FFIError
from .ffiplatform import VerificationError, VerificationMissing
-__version__ = "0.6"
-__version_info__ = (0, 6)
+__version__ = "0.7"
+__version_info__ = (0, 7)
diff --git a/lib_pypy/cffi/api.py b/lib_pypy/cffi/api.py
--- a/lib_pypy/cffi/api.py
+++ b/lib_pypy/cffi/api.py
@@ -73,15 +73,15 @@
if name.startswith('RTLD_'):
setattr(self, name, getattr(backend, name))
#
- BVoidP = self._get_cached_btype(model.voidp_type)
+ self.BVoidP = self._get_cached_btype(model.voidp_type)
if isinstance(backend, types.ModuleType):
# _cffi_backend: attach these constants to the class
if not hasattr(FFI, 'NULL'):
- FFI.NULL = self.cast(BVoidP, 0)
+ FFI.NULL = self.cast(self.BVoidP, 0)
FFI.CData, FFI.CType = backend._get_types()
else:
# ctypes backend: attach these constants to the instance
- self.NULL = self.cast(BVoidP, 0)
+ self.NULL = self.cast(self.BVoidP, 0)
self.CData, self.CType = backend._get_types()
def cdef(self, csource, override=False):
@@ -346,6 +346,12 @@
self._cdefsources.extend(ffi_to_include._cdefsources)
self._cdefsources.append(']')
+ def new_handle(self, x):
+ return self._backend.newp_handle(self.BVoidP, x)
+
+ def from_handle(self, x):
+ return self._backend.from_handle(x)
+
def _make_ffi_library(ffi, libname, flags):
import os
@@ -355,13 +361,13 @@
backend = ffi._backend
try:
if '.' not in name and '/' not in name:
- raise OSError
+ raise OSError("library not found: %r" % (name,))
backendlib = backend.load_library(name, flags)
except OSError:
import ctypes.util
path = ctypes.util.find_library(name)
if path is None:
- raise OSError("library not found: %r" % (name,))
+ raise # propagate the original OSError
backendlib = backend.load_library(path, flags)
copied_enums = []
#
@@ -372,8 +378,8 @@
BType = ffi._get_cached_btype(tp)
try:
value = backendlib.load_function(BType, name)
- except KeyError:
- raise AttributeError(name)
+ except KeyError as e:
+ raise AttributeError('%s: %s' % (name, e))
library.__dict__[name] = value
return
#
diff --git a/lib_pypy/cffi/backend_ctypes.py b/lib_pypy/cffi/backend_ctypes.py
--- a/lib_pypy/cffi/backend_ctypes.py
+++ b/lib_pypy/cffi/backend_ctypes.py
@@ -16,6 +16,7 @@
class CTypesData(object):
__metaclass__ = CTypesType
__slots__ = ['__weakref__']
+ __name__ = '<cdata>'
def __init__(self, *args):
raise TypeError("cannot instantiate %r" % (self.__class__,))
@@ -491,6 +492,8 @@
elif BItem in (getbtype(model.PrimitiveType('signed char')),
getbtype(model.PrimitiveType('unsigned char'))):
kind = 'bytep'
+ elif BItem is getbtype(model.void_type):
+ kind = 'voidp'
else:
kind = 'generic'
#
@@ -546,13 +549,13 @@
def __setitem__(self, index, value):
self._as_ctype_ptr[index] = BItem._to_ctypes(value)
- if kind == 'charp':
+ if kind == 'charp' or kind == 'voidp':
@classmethod
- def _arg_to_ctypes(cls, value):
- if isinstance(value, bytes):
- return ctypes.c_char_p(value)
+ def _arg_to_ctypes(cls, *value):
+ if value and isinstance(value[0], bytes):
+ return ctypes.c_char_p(value[0])
else:
- return super(CTypesPtr, cls)._arg_to_ctypes(value)
+ return super(CTypesPtr, cls)._arg_to_ctypes(*value)
if kind == 'charp' or kind == 'bytep':
def _to_string(self, maxlen):
diff --git a/lib_pypy/cffi/vengine_cpy.py b/lib_pypy/cffi/vengine_cpy.py
--- a/lib_pypy/cffi/vengine_cpy.py
+++ b/lib_pypy/cffi/vengine_cpy.py
@@ -15,6 +15,20 @@
def patch_extension_kwds(self, kwds):
pass
+ def find_module(self, module_name, path, so_suffix):
+ try:
+ f, filename, descr = imp.find_module(module_name, path)
+ except ImportError:
+ return None
+ if f is not None:
+ f.close()
+ # Note that after a setuptools installation, there are both .py
+ # and .so files with the same basename. The code here relies on
+ # imp.find_module() locating the .so in priority.
+ if descr[0] != so_suffix:
+ return None
+ return filename
+
def collect_types(self):
self._typesdict = {}
self._generate("collecttype")
@@ -142,6 +156,9 @@
class FFILibrary(object):
_cffi_python_module = module
_cffi_ffi = self.ffi
+ _cffi_dir = []
+ def __dir__(self):
+ return FFILibrary._cffi_dir + list(self.__dict__)
library = FFILibrary()
module._cffi_setup(lst, ffiplatform.VerificationError, library)
#
@@ -427,9 +444,9 @@
prnt('static void %s(%s *p)' % (checkfuncname, cname))
prnt('{')
prnt(' /* only to generate compile-time warnings or errors */')
- for fname, ftype, _ in tp.enumfields():
+ for fname, ftype, fbitsize in tp.enumfields():
if (isinstance(ftype, model.PrimitiveType)
- and ftype.is_integer_type()):
+ and ftype.is_integer_type()) or fbitsize >= 0:
# accept all integers, but complain on float or double
prnt(' (void)((p->%s) << 1);' % fname)
else:
@@ -687,7 +704,8 @@
return ptr[0]
def setter(library, value):
ptr[0] = value
- setattr(library.__class__, name, property(getter, setter))
+ setattr(type(library), name, property(getter, setter))
+ type(library)._cffi_dir.append(name)
# ----------
diff --git a/lib_pypy/cffi/vengine_gen.py b/lib_pypy/cffi/vengine_gen.py
--- a/lib_pypy/cffi/vengine_gen.py
+++ b/lib_pypy/cffi/vengine_gen.py
@@ -1,4 +1,4 @@
-import sys
+import sys, os
import types
from . import model, ffiplatform
@@ -20,6 +20,16 @@
# up in kwds['export_symbols'].
kwds.setdefault('export_symbols', self.export_symbols)
+ def find_module(self, module_name, path, so_suffix):
+ basename = module_name + so_suffix
+ if path is None:
+ path = sys.path
+ for dirname in path:
+ filename = os.path.join(dirname, basename)
+ if os.path.isfile(filename):
+ return filename
+ return None
+
def collect_types(self):
pass # not needed in the generic engine
@@ -64,6 +74,9 @@
class FFILibrary(types.ModuleType):
_cffi_generic_module = module
_cffi_ffi = self.ffi
+ _cffi_dir = []
+ def __dir__(self):
+ return FFILibrary._cffi_dir
library = FFILibrary("")
#
# finally, call the loaded_gen_xxx() functions. This will set
@@ -158,21 +171,22 @@
newfunction = self._load_constant(False, tp, name, module)
else:
indirections = []
- if any(isinstance(type, model.StructOrUnion) for type in tp.args):
+ if any(isinstance(typ, model.StructOrUnion) for typ in tp.args):
indirect_args = []
- for i, type in enumerate(tp.args):
- if isinstance(type, model.StructOrUnion):
- type = model.PointerType(type)
- indirections.append((i, type))
- indirect_args.append(type)
+ for i, typ in enumerate(tp.args):
+ if isinstance(typ, model.StructOrUnion):
+ typ = model.PointerType(typ)
+ indirections.append((i, typ))
+ indirect_args.append(typ)
tp = model.FunctionPtrType(tuple(indirect_args),
tp.result, tp.ellipsis)
BFunc = self.ffi._get_cached_btype(tp)
wrappername = '_cffi_f_%s' % name
newfunction = module.load_function(BFunc, wrappername)
- for i, type in indirections:
- newfunction = self._make_struct_wrapper(newfunction, i, type)
+ for i, typ in indirections:
+ newfunction = self._make_struct_wrapper(newfunction, i, typ)
setattr(library, name, newfunction)
+ type(library)._cffi_dir.append(name)
def _make_struct_wrapper(self, oldfunc, i, tp):
backend = self.ffi._backend
@@ -216,9 +230,9 @@
prnt('static void %s(%s *p)' % (checkfuncname, cname))
prnt('{')
prnt(' /* only to generate compile-time warnings or errors */')
- for fname, ftype, _ in tp.enumfields():
+ for fname, ftype, fbitsize in tp.enumfields():
if (isinstance(ftype, model.PrimitiveType)
- and ftype.is_integer_type()):
+ and ftype.is_integer_type()) or fbitsize >= 0:
# accept all integers, but complain on float or double
prnt(' (void)((p->%s) << 1);' % fname)
else:
@@ -380,6 +394,7 @@
is_int = isinstance(tp, model.PrimitiveType) and tp.is_integer_type()
value = self._load_constant(is_int, tp, name, module)
setattr(library, name, value)
+ type(library)._cffi_dir.append(name)
# ----------
# enums
@@ -427,6 +442,7 @@
def _loaded_gen_enum(self, tp, name, module, library):
for enumerator, enumvalue in zip(tp.enumerators, tp.enumvalues):
setattr(library, enumerator, enumvalue)
+ type(library)._cffi_dir.append(enumerator)
# ----------
# macros: for now only for integers
@@ -440,6 +456,7 @@
def _loaded_gen_macro(self, tp, name, module, library):
value = self._load_constant(True, tp, name, module)
setattr(library, name, value)
+ type(library)._cffi_dir.append(name)
# ----------
# global variables
@@ -465,6 +482,7 @@
BArray = self.ffi._get_cached_btype(tp)
value = self.ffi.cast(BArray, value)
setattr(library, name, value)
+ type(library)._cffi_dir.append(name)
return
# remove ptr=<cdata 'int *'> from the library instance, and replace
# it by a property on the class, which reads/writes into ptr[0].
@@ -476,7 +494,8 @@
return ptr[0]
def setter(library, value):
ptr[0] = value
- setattr(library.__class__, name, property(getter, setter))
+ setattr(type(library), name, property(getter, setter))
+ type(library)._cffi_dir.append(name)
cffimod_header = r'''
#include <stdio.h>
diff --git a/lib_pypy/cffi/verifier.py b/lib_pypy/cffi/verifier.py
--- a/lib_pypy/cffi/verifier.py
+++ b/lib_pypy/cffi/verifier.py
@@ -102,21 +102,10 @@
path = pkg.__path__
else:
path = None
- try:
- f, filename, descr = imp.find_module(self.get_module_name(),
- path)
- except ImportError:
+ filename = self._vengine.find_module(self.get_module_name(), path,
+ _get_so_suffix())
+ if filename is None:
return
- if f is not None:
- f.close()
- if filename.lower().endswith('.py'):
- # on PyPy, if there are both .py and .pypy-19.so files in
- # the same directory, the .py file is returned. That's the
- # case after a setuptools installation. We never want to
- # load the .py file here...
- filename = filename[:-3] + _get_so_suffix()
- if not os.path.isfile(filename):
- return
self.modulefilename = filename
self._vengine.collect_types()
self._has_module = True
diff --git a/lib_pypy/greenlet.egg-info b/lib_pypy/greenlet.egg-info
new file mode 100644
--- /dev/null
+++ b/lib_pypy/greenlet.egg-info
@@ -0,0 +1,10 @@
+Metadata-Version: 1.0
+Name: greenlet
+Version: 0.4.0
+Summary: Lightweight in-process concurrent programming
+Home-page: https://github.com/python-greenlet/greenlet
+Author: Ralf Schmitt (for CPython), PyPy team
+Author-email: pypy-dev at python.org
+License: MIT License
+Description: UNKNOWN
+Platform: UNKNOWN
diff --git a/pypy/bin/pyinteractive.py b/pypy/bin/pyinteractive.py
--- a/pypy/bin/pyinteractive.py
+++ b/pypy/bin/pyinteractive.py
@@ -27,7 +27,8 @@
BoolOption("completer", "use readline commandline completer",
default=False, cmdline="-C"),
BoolOption("optimize",
- "dummy optimization flag for compatibility with CPython",
+ "skip assert statements and remove docstrings when importing modules"
+ " (this is -OO in regular CPython)",
default=False, cmdline="-O"),
BoolOption("no_site_import", "do not 'import site' on initialization",
default=False, cmdline="-S"),
@@ -94,6 +95,17 @@
space.setitem(space.sys.w_dict, space.wrap('executable'),
space.wrap(argv[0]))
+ if interactiveconfig.optimize:
+ #change the optimize flag's value and set __debug__ to False
+ space.appexec([], """():
+ import sys
+ flags = list(sys.flags)
+ flags[6] = 2
+ sys.flags = type(sys.flags)(flags)
+ import __pypy__
+ __pypy__.set_debug(False)
+ """)
+
# call pypy_find_stdlib: the side-effect is that it sets sys.prefix and
# sys.exec_prefix
executable = argv[0]
diff --git a/pypy/config/pypyoption.py b/pypy/config/pypyoption.py
--- a/pypy/config/pypyoption.py
+++ b/pypy/config/pypyoption.py
@@ -64,7 +64,8 @@
del working_modules["termios"]
del working_modules["_minimal_curses"]
- del working_modules["cppyy"] # not tested on win32
+ if "cppyy" in working_modules:
+ del working_modules["cppyy"] # not tested on win32
# The _locale module is needed by site.py on Windows
default_modules["_locale"] = None
@@ -77,7 +78,8 @@
del working_modules["_minimal_curses"]
del working_modules["termios"]
del working_modules["_multiprocessing"] # depends on rctime
- del working_modules["cppyy"] # depends on ctypes
+ if "cppyy" in working_modules:
+ del working_modules["cppyy"] # depends on ctypes
module_dependencies = {
@@ -120,12 +122,10 @@
__import__(name)
except (ImportError, CompilationError, py.test.skip.Exception), e:
errcls = e.__class__.__name__
- config.add_warning(
+ raise Exception(
"The module %r is disabled\n" % (modname,) +
"because importing %s raised %s\n" % (name, errcls) +
str(e))
- raise ConflictConfigError("--withmod-%s: %s" % (modname,
- errcls))
return validator
else:
return None
@@ -216,10 +216,6 @@
"(the empty string and potentially single-char strings)",
default=False),
- BoolOption("withsmalltuple",
- "use small tuples",
- default=False),
-
BoolOption("withspecialisedtuple",
"use specialised tuples",
default=False),
@@ -364,6 +360,7 @@
# ignore names from 'essential_modules', notably 'exceptions', which
# may not be present in config.objspace.usemodules at all
modules = [name for name in modules if name not in essential_modules]
+
config.objspace.usemodules.suggest(**dict.fromkeys(modules, True))
def enable_translationmodules(config):
diff --git a/pypy/doc/__pypy__-module.rst b/pypy/doc/__pypy__-module.rst
--- a/pypy/doc/__pypy__-module.rst
+++ b/pypy/doc/__pypy__-module.rst
@@ -1,3 +1,6 @@
+.. comment: this document is very incomplete, should we generate
+ it automatically?
+
The ``__pypy__`` module
=======================
diff --git a/pypy/doc/conf.py b/pypy/doc/conf.py
--- a/pypy/doc/conf.py
+++ b/pypy/doc/conf.py
@@ -47,7 +47,7 @@
# The short X.Y version.
version = '2.0'
# The full version, including alpha/beta/rc tags.
-release = '2.0.0'
+release = '2.0.2'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
diff --git a/pypy/doc/cppyy.rst b/pypy/doc/cppyy.rst
--- a/pypy/doc/cppyy.rst
+++ b/pypy/doc/cppyy.rst
@@ -157,6 +157,9 @@
$ genreflex MyClass.h
$ g++ -fPIC -rdynamic -O2 -shared -I$REFLEXHOME/include MyClass_rflx.cpp -o libMyClassDict.so -L$REFLEXHOME/lib -lReflex
+Next, make sure that the library can be found through the dynamic lookup path
+(the ``LD_LIBRARY_PATH`` environment variable on Linux, ``PATH`` on Windows),
+for example by adding ".".
Now you're ready to use the bindings.
Since the bindings are designed to look pythonistic, it should be
straightforward::
diff --git a/pypy/doc/how-to-contribute.rst b/pypy/doc/how-to-contribute.rst
--- a/pypy/doc/how-to-contribute.rst
+++ b/pypy/doc/how-to-contribute.rst
@@ -33,7 +33,8 @@
Layers
------
-PyPy has layers. Those layers help us keep the respective parts separated enough
+PyPy has layers. Just like Ogres or onions.
+Those layers help us keep the respective parts separated enough
to be worked on independently and make the complexity manageable. This is,
again, just a sanity requirement for such a complex project. For example writing
a new optimization for the JIT usually does **not** involve touching a Python
diff --git a/pypy/doc/how-to-release.rst b/pypy/doc/how-to-release.rst
--- a/pypy/doc/how-to-release.rst
+++ b/pypy/doc/how-to-release.rst
@@ -22,7 +22,8 @@
will capture the revision number of this change for the release;
some of the next updates may be done before or after branching; make
sure things are ported back to the trunk and to the branch as
- necessary
+ necessary; also update the version number in pypy/doc/conf.py,
+ and in pypy/doc/index.rst
* update pypy/doc/contributor.rst (and possibly LICENSE)
* rename pypy/doc/whatsnew_head.rst to whatsnew_VERSION.rst
and create a fresh whatsnew_head.rst after the release
diff --git a/pypy/doc/index-old.rst b/pypy/doc/index-old.rst
--- a/pypy/doc/index-old.rst
+++ b/pypy/doc/index-old.rst
@@ -43,7 +43,7 @@
* :doc:`FAQ <faq>`: some frequently asked questions.
-* `Release 2.0`_: the latest official release
+* `Release 2.0.2`_: the latest official release
* `PyPy Blog`_: news and status info about PyPy
@@ -57,7 +57,7 @@
particularly organized
.. _PyPy blog: http://morepypy.blogspot.com/
-.. _Release 2.0: http://pypy.org/download.html
+.. _Release 2.0.2: http://pypy.org/download.html
.. _speed.pypy.org: http://speed.pypy.org
.. toctree::
diff --git a/pypy/doc/man/pypy.1.rst b/pypy/doc/man/pypy.1.rst
--- a/pypy/doc/man/pypy.1.rst
+++ b/pypy/doc/man/pypy.1.rst
@@ -16,7 +16,10 @@
Inspect interactively after running script.
-O
- Dummy optimization flag for compatibility with C Python.
+ Skip assert statements.
+
+-OO
+ Remove docstrings when importing modules in addition to -O.
-c *cmd*
Program passed in as CMD (terminates option list).
diff --git a/pypy/doc/release-2.0.1.rst b/pypy/doc/release-2.0.1.rst
new file mode 100644
--- /dev/null
+++ b/pypy/doc/release-2.0.1.rst
@@ -0,0 +1,46 @@
+==============================
+PyPy 2.0.1 - Bohr Smørrebrød
+==============================
+
+We're pleased to announce PyPy 2.0.1. This is a stable bugfix release
+over `2.0`_. You can download it here:
+
+ http://pypy.org/download.html
+
+The fixes are mainly about fatal errors or crashes in our stdlib. See
+below for more details.
+
+What is PyPy?
+=============
+
+PyPy is a very compliant Python interpreter, almost a drop-in replacement for
+CPython 2.7. It's fast (`pypy 2.0 and cpython 2.7.3`_ performance comparison)
+due to its integrated tracing JIT compiler.
+
+This release supports x86 machines running Linux 32/64, Mac OS X 64 or
+Windows 32. Support for ARM is progressing but not bug-free yet.
+
+.. _`pypy 2.0 and cpython 2.7.3`: http://speed.pypy.org
+
+Highlights
+==========
+
+- fix an occasional crash in the JIT that ends in `RPython Fatal error:
+ NotImplementedError`__.
+
+- `id(x)` is now always a positive number (except on int/float/long/complex).
+ This fixes an issue in ``_sqlite.py`` (mostly for 32-bit Linux).
+
+- fix crashes of callback-from-C-functions (with cffi) when used together
+ with Stackless features, on asmgcc (i.e. Linux only). Now `gevent should
+ work better`__.
+
+- work around an eventlet issue with `socket._decref_socketios()`__.
+
+.. __: https://bugs.pypy.org/issue1482
+.. __: http://mail.python.org/pipermail/pypy-dev/2013-May/011362.html
+.. __: https://bugs.pypy.org/issue1468
+.. _2.0: release-2.0.0.html
+
+Cheers,
+arigo et. al. for the PyPy team
diff --git a/pypy/doc/release-2.0.2.rst b/pypy/doc/release-2.0.2.rst
new file mode 100644
--- /dev/null
+++ b/pypy/doc/release-2.0.2.rst
@@ -0,0 +1,46 @@
+=========================
+PyPy 2.0.2 - Fermi Panini
+=========================
+
+We're pleased to announce PyPy 2.0.2. This is a stable bugfix release
+over `2.0`_ and `2.0.1`_. You can download it here:
+
+ http://pypy.org/download.html
+
+It fixes a crash in the JIT when calling external C functions (with
+ctypes/cffi) in a multithreaded context.
+
+.. _2.0: release-2.0.0.html
+.. _2.0.1: release-2.0.1.html
+
+What is PyPy?
+=============
+
+PyPy is a very compliant Python interpreter, almost a drop-in replacement for
+CPython 2.7. It's fast (`pypy 2.0 and cpython 2.7.3`_ performance comparison)
+due to its integrated tracing JIT compiler.
+
+This release supports x86 machines running Linux 32/64, Mac OS X 64 or
+Windows 32. Support for ARM is progressing but not bug-free yet.
+
+.. _`pypy 2.0 and cpython 2.7.3`: http://speed.pypy.org
+
+Highlights
+==========
+
+This release contains only the fix described above. A crash (or wrong
+results) used to occur if all these conditions were true:
+
+- your program is multithreaded;
+
+- it runs on a single-core machine or a heavily-loaded multi-core one;
+
+- it uses ctypes or cffi to issue external calls to C functions.
+
+This was fixed in the branch `emit-call-x86`__ (see the example file
+``bug1.py``).
+
+.. __: https://bitbucket.org/pypy/pypy/commits/7c80121abbf4
+
+Cheers,
+arigo et. al. for the PyPy team
diff --git a/pypy/doc/test/test_whatsnew.py b/pypy/doc/test/test_whatsnew.py
--- a/pypy/doc/test/test_whatsnew.py
+++ b/pypy/doc/test/test_whatsnew.py
@@ -19,23 +19,28 @@
branches.discard('default')
return startrev, branches
-def get_merged_branches(path, startrev, endrev):
- if getstatusoutput('hg root')[0]:
+def get_merged_branches(path, startrev, endrev, current_branch=None):
+ errcode, wc_branch = getstatusoutput('hg branch')
+ if errcode != 0:
py.test.skip('no Mercurial repo')
+ if current_branch is None:
+ current_branch = wc_branch
# X = take all the merges which are descendants of startrev and are on default
# revset = all the parents of X which are not on default
# ===>
# revset contains all the branches which have been merged to default since
# startrev
- revset = 'parents(%s::%s and \
+ revset = "parents(%s::%s and \
merge() and \
- branch(default)) and \
- not branch(default)' % (startrev, endrev)
+ branch('%s')) and \
+ not branch('%s')" % (startrev, endrev,
+ current_branch, current_branch)
cmd = r'hg log -R "%s" -r "%s" --template "{branches}\n"' % (path, revset)
out = getoutput(cmd)
branches = set(map(str.strip, out.splitlines()))
- return branches
+ branches.discard("default")
+ return branches, current_branch
def test_parse_doc():
@@ -65,7 +70,8 @@
assert branches == set(['foobar', 'hello'])
def test_get_merged_branches():
- branches = get_merged_branches(ROOT, 'f34f0c11299f', '79770e0c2f93')
+ branches, _ = get_merged_branches(ROOT, 'f34f0c11299f', '79770e0c2f93',
+ 'default')
assert branches == set(['numpy-indexing-by-arrays-bool',
'better-jit-hooks-2',
'numpypy-ufuncs'])
@@ -76,7 +82,9 @@
whatsnew_list.sort()
last_whatsnew = whatsnew_list[-1].read()
startrev, documented = parse_doc(last_whatsnew)
- merged = get_merged_branches(ROOT, startrev, '')
+ merged, branch = get_merged_branches(ROOT, startrev, '')
+ merged.discard('default')
+ merged.discard('')
not_documented = merged.difference(documented)
not_merged = documented.difference(merged)
print 'Branches merged but not documented:'
@@ -85,4 +93,6 @@
print 'Branches documented but not merged:'
print '\n'.join(not_merged)
print
- assert not not_documented and not not_merged
+ assert not not_documented
+ if branch == 'default':
+ assert not not_merged
diff --git a/pypy/doc/whatsnew-head.rst b/pypy/doc/whatsnew-head.rst
--- a/pypy/doc/whatsnew-head.rst
+++ b/pypy/doc/whatsnew-head.rst
@@ -7,3 +7,48 @@
.. branch: numpy-pickle
Pickling of numpy arrays and dtypes (including record dtypes)
+
+.. branch: remove-array-smm
+Remove multimethods in the arraymodule
+
+.. branch: callback-stacklet
+Fixed bug when switching stacklets from a C callback
+
+.. branch: remove-set-smm
+Remove multi-methods on sets
+
+.. branch: numpy-subarrays
+Implement subarrays for numpy
+
+.. branch: remove-dict-smm
+Remove multi-methods on dict
+
+.. branch: remove-list-smm-2
+Remove remaining multi-methods on list
+
+.. branch: arm-stacklet
+Stacklet support for ARM, enables _continuation support
+
+.. branch: remove-tuple-smm
+Remove multi-methods on tuple
+
+.. branch: remove-iter-smm
+Remove multi-methods on iterators
+
+.. branch: emit-call-x86
+.. branch: emit-call-arm
+
+.. branch: on-abort-resops
+Added list of resops to the pypyjit on_abort hook.
+
+.. branch: logging-perf
+Speeds up the stdlib logging module
+
+.. branch: operrfmt-NT
+Adds a couple convenient format specifiers to operationerrfmt
+
+.. branch: win32-fixes3
+Skip and fix some non-translated (own) tests for win32 builds
+
+.. branch: ctypes-byref
+Add the '_obj' attribute on ctypes pointer() and byref() objects
diff --git a/pypy/goal/getnightly.py b/pypy/goal/getnightly.py
--- a/pypy/goal/getnightly.py
+++ b/pypy/goal/getnightly.py
@@ -8,7 +8,9 @@
arch = 'linux'
cmd = 'wget "%s"'
tar = "tar -x -v --wildcards --strip-components=2 -f %s '*/bin/pypy'"
-if sys.platform.startswith('darwin'):
+ if os.uname()[-1].startswith('arm'):
+ arch += '-armhf-raspbian'
+elif sys.platform.startswith('darwin'):
arch = 'osx'
cmd = 'curl -O "%s"'
tar = "tar -x -v --strip-components=2 -f %s '*/bin/pypy'"
diff --git a/pypy/goal/targetpypystandalone.py b/pypy/goal/targetpypystandalone.py
--- a/pypy/goal/targetpypystandalone.py
+++ b/pypy/goal/targetpypystandalone.py
@@ -2,6 +2,7 @@
import os, sys
+import pypy
from pypy.interpreter import gateway
from pypy.interpreter.error import OperationError
from pypy.tool.ann_override import PyPyAnnotatorPolicy
@@ -9,6 +10,8 @@
from rpython.config.config import ConflictConfigError
from pypy.tool.option import make_objspace
from pypy.conftest import pypydir
+from rpython.rlib import rthread
+from pypy.module.thread import os_thread
thisdir = py.path.local(__file__).dirpath()
@@ -78,13 +81,65 @@
# should be used as sparsely as possible, just to register callbacks
from rpython.rlib.entrypoint import entrypoint
- from rpython.rtyper.lltypesystem import rffi
+ from rpython.rtyper.lltypesystem import rffi, lltype
+
+ w_pathsetter = space.appexec([], """():
+ def f(path):
+ import sys
+ sys.path[:] = path
+ return f
+ """)
+
+ @entrypoint('main', [rffi.CCHARP, lltype.Signed], c_name='pypy_setup_home')
+ def pypy_setup_home(ll_home, verbose):
+ from pypy.module.sys.initpath import pypy_find_stdlib
+ if ll_home:
+ home = rffi.charp2str(ll_home)
+ else:
+ home = pypydir
+ w_path = pypy_find_stdlib(space, home)
+ if space.is_none(w_path):
+ if verbose:
+ debug("Failed to find library based on pypy_find_stdlib")
+ return 1
+ space.startup()
+ space.call_function(w_pathsetter, w_path)
+ # import site
+ try:
+ import_ = space.getattr(space.getbuiltinmodule('__builtin__'),
+ space.wrap('__import__'))
+ space.call_function(import_, space.wrap('site'))
+ return 0
+ except OperationError, e:
+ if verbose:
+ debug("OperationError:")
+ debug(" operror-type: " + e.w_type.getname(space))
+ debug(" operror-value: " + space.str_w(space.str(e.get_w_value(space))))
+ return 1
@entrypoint('main', [rffi.CCHARP], c_name='pypy_execute_source')
def pypy_execute_source(ll_source):
source = rffi.charp2str(ll_source)
return _pypy_execute_source(source)
+ @entrypoint('main', [], c_name='pypy_init_threads')
+ def pypy_init_threads():
+ if not space.config.objspace.usemodules.thread:
+ return
+ os_thread.setup_threads(space)
+ rffi.aroundstate.before()
+
+ @entrypoint('main', [], c_name='pypy_thread_attach')
+ def pypy_thread_attach():
+ if not space.config.objspace.usemodules.thread:
+ return
+ os_thread.setup_threads(space)
+ os_thread.bootstrapper.acquire(space, None, None)
+ rthread.gc_thread_start()
+ os_thread.bootstrapper.nbthreads += 1
+ os_thread.bootstrapper.release()
+ rffi.aroundstate.before()
+
w_globals = space.newdict()
space.setitem(w_globals, space.wrap('__builtins__'),
space.builtin_modules['__builtin__'])
@@ -101,7 +156,10 @@
return 1
return 0
- return entry_point, _pypy_execute_source # for tests
+ return entry_point, {'pypy_execute_source': pypy_execute_source,
+ 'pypy_init_threads': pypy_init_threads,
+ 'pypy_thread_attach': pypy_thread_attach,
+ 'pypy_setup_home': pypy_setup_home}
def call_finish(space):
space.finish()
diff --git a/pypy/interpreter/app_main.py b/pypy/interpreter/app_main.py
--- a/pypy/interpreter/app_main.py
+++ b/pypy/interpreter/app_main.py
@@ -2,8 +2,8 @@
# App-level version of py.py.
# See test/test_app_main.
-# Missing vs CPython: -d, -OO, -t, -v, -x, -3
-"""\
+# Missing vs CPython: -d, -t, -v, -x, -3
+USAGE1 = __doc__ = """\
Options and arguments (and corresponding environment variables):
-B : don't write .py[co] files on import; also PYTHONDONTWRITEBYTECODE=x
-c cmd : program passed in as string (terminates option list)
@@ -12,7 +12,8 @@
-i : inspect interactively after running script; forces a prompt even
if stdin does not appear to be a terminal; also PYTHONINSPECT=x
-m mod : run library module as a script (terminates option list)
--O : dummy optimization flag for compatibility with CPython
+-O : skip assert statements
+-OO : remove docstrings when importing modules in addition to -O
-R : ignored (see http://bugs.python.org/issue14621)
-Q arg : division options: -Qold (default), -Qwarn, -Qwarnall, -Qnew
-s : don't add user site directory to sys.path; also PYTHONNOUSERSITE
@@ -27,7 +28,6 @@
PyPy options and arguments:
--info : print translation information about this PyPy executable
"""
-USAGE1 = __doc__
# Missing vs CPython: PYTHONHOME, PYTHONCASEOK
USAGE2 = """
Other environment variables:
@@ -470,6 +470,10 @@
sys.py3kwarning = bool(sys.flags.py3k_warning)
sys.dont_write_bytecode = bool(sys.flags.dont_write_bytecode)
+ if sys.flags.optimize >= 1:
+ import __pypy__
+ __pypy__.set_debug(False)
+
if sys.py3kwarning:
print >> sys.stderr, (
"Warning: pypy does not implement py3k warnings")
diff --git a/pypy/interpreter/argument.py b/pypy/interpreter/argument.py
--- a/pypy/interpreter/argument.py
+++ b/pypy/interpreter/argument.py
@@ -86,12 +86,9 @@
args_w = space.fixedview(w_stararg)
except OperationError, e:
if e.match(space, space.w_TypeError):
- w_type = space.type(w_stararg)
- typename = w_type.getname(space)
- raise OperationError(
+ raise operationerrfmt(
space.w_TypeError,
- space.wrap("argument after * must be "
- "a sequence, not %s" % (typename,)))
+ "argument after * must be a sequence, not %T", w_stararg)
raise
self.arguments_w = self.arguments_w + args_w
@@ -116,12 +113,10 @@
w_keys = space.call_method(w_starstararg, "keys")
except OperationError, e:
if e.match(space, space.w_AttributeError):
- w_type = space.type(w_starstararg)
- typename = w_type.getname(space)
- raise OperationError(
+ raise operationerrfmt(
space.w_TypeError,
- space.wrap("argument after ** must be "
- "a mapping, not %s" % (typename,)))
+ "argument after ** must be a mapping, not %T",
+ w_starstararg)
raise
keys_w = space.unpackiterable(w_keys)
keywords_w = [None] * len(keys_w)
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
@@ -245,6 +245,8 @@
if w_len is None:
w_len = space.len(self.w_consts)
space.setitem(self.w_consts, w_key, w_len)
+ if space.int_w(w_len) == 0:
+ self.scope.doc_removable = False
return space.int_w(w_len)
def _make_key(self, obj):
@@ -632,6 +634,7 @@
ops.JUMP_IF_FALSE_OR_POP : 0,
ops.POP_JUMP_IF_TRUE : -1,
ops.POP_JUMP_IF_FALSE : -1,
+ ops.JUMP_IF_NOT_DEBUG : 0,
ops.BUILD_LIST_FROM_ARG: 1,
}
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
@@ -2793,8 +2793,7 @@
def Module_get_body(space, w_self):
if not w_self.initialization_state & 1:
- typename = space.type(w_self).getname(space)
- raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'body')
+ raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'body')
if w_self.w_body is None:
if w_self.body is None:
list_w = []
@@ -2835,8 +2834,7 @@
def Interactive_get_body(space, w_self):
if not w_self.initialization_state & 1:
- typename = space.type(w_self).getname(space)
- raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'body')
+ raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'body')
if w_self.w_body is None:
if w_self.body is None:
list_w = []
@@ -2881,8 +2879,7 @@
if w_obj is not None:
return w_obj
if not w_self.initialization_state & 1:
- typename = space.type(w_self).getname(space)
- raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'body')
+ raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'body')
return space.wrap(w_self.body)
def Expression_set_body(space, w_self, w_new_value):
@@ -2925,8 +2922,7 @@
def Suite_get_body(space, w_self):
if not w_self.initialization_state & 1:
- typename = space.type(w_self).getname(space)
- raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'body')
+ raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'body')
if w_self.w_body is None:
if w_self.body is None:
list_w = []
@@ -2971,8 +2967,7 @@
if w_obj is not None:
return w_obj
if not w_self.initialization_state & 1:
- typename = space.type(w_self).getname(space)
- raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'lineno')
+ raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'lineno')
return space.wrap(w_self.lineno)
def stmt_set_lineno(space, w_self, w_new_value):
@@ -2993,8 +2988,7 @@
if w_obj is not None:
return w_obj
if not w_self.initialization_state & 2:
- typename = space.type(w_self).getname(space)
- raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'col_offset')
+ raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'col_offset')
return space.wrap(w_self.col_offset)
def stmt_set_col_offset(space, w_self, w_new_value):
@@ -3024,8 +3018,7 @@
if w_obj is not None:
return w_obj
if not w_self.initialization_state & 4:
- typename = space.type(w_self).getname(space)
- raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'name')
+ raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'name')
return space.wrap(w_self.name)
def FunctionDef_set_name(space, w_self, w_new_value):
@@ -3046,8 +3039,7 @@
if w_obj is not None:
return w_obj
if not w_self.initialization_state & 8:
- typename = space.type(w_self).getname(space)
- raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'args')
+ raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'args')
return space.wrap(w_self.args)
def FunctionDef_set_args(space, w_self, w_new_value):
@@ -3064,8 +3056,7 @@
def FunctionDef_get_body(space, w_self):
if not w_self.initialization_state & 16:
- typename = space.type(w_self).getname(space)
- raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'body')
+ raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'body')
if w_self.w_body is None:
if w_self.body is None:
list_w = []
@@ -3081,8 +3072,7 @@
def FunctionDef_get_decorator_list(space, w_self):
if not w_self.initialization_state & 32:
- typename = space.type(w_self).getname(space)
- raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'decorator_list')
+ raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'decorator_list')
if w_self.w_decorator_list is None:
if w_self.decorator_list is None:
list_w = []
@@ -3131,8 +3121,7 @@
if w_obj is not None:
return w_obj
if not w_self.initialization_state & 4:
- typename = space.type(w_self).getname(space)
- raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'name')
+ raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'name')
return space.wrap(w_self.name)
def ClassDef_set_name(space, w_self, w_new_value):
@@ -3149,8 +3138,7 @@
def ClassDef_get_bases(space, w_self):
if not w_self.initialization_state & 8:
- typename = space.type(w_self).getname(space)
- raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'bases')
+ raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'bases')
if w_self.w_bases is None:
if w_self.bases is None:
list_w = []
@@ -3166,8 +3154,7 @@
def ClassDef_get_body(space, w_self):
if not w_self.initialization_state & 16:
- typename = space.type(w_self).getname(space)
- raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'body')
+ raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'body')
if w_self.w_body is None:
if w_self.body is None:
list_w = []
@@ -3183,8 +3170,7 @@
def ClassDef_get_decorator_list(space, w_self):
if not w_self.initialization_state & 32:
- typename = space.type(w_self).getname(space)
- raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'decorator_list')
+ raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'decorator_list')
if w_self.w_decorator_list is None:
if w_self.decorator_list is None:
list_w = []
@@ -3234,8 +3220,7 @@
if w_obj is not None:
return w_obj
if not w_self.initialization_state & 4:
- typename = space.type(w_self).getname(space)
- raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'value')
+ raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'value')
return space.wrap(w_self.value)
def Return_set_value(space, w_self, w_new_value):
@@ -3278,8 +3263,7 @@
def Delete_get_targets(space, w_self):
if not w_self.initialization_state & 4:
- typename = space.type(w_self).getname(space)
- raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'targets')
+ raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'targets')
if w_self.w_targets is None:
if w_self.targets is None:
list_w = []
@@ -3320,8 +3304,7 @@
def Assign_get_targets(space, w_self):
if not w_self.initialization_state & 4:
- typename = space.type(w_self).getname(space)
- raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'targets')
+ raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'targets')
if w_self.w_targets is None:
if w_self.targets is None:
list_w = []
@@ -3341,8 +3324,7 @@
if w_obj is not None:
return w_obj
if not w_self.initialization_state & 8:
- typename = space.type(w_self).getname(space)
- raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'value')
+ raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'value')
return space.wrap(w_self.value)
def Assign_set_value(space, w_self, w_new_value):
@@ -3391,8 +3373,7 @@
if w_obj is not None:
return w_obj
if not w_self.initialization_state & 4:
- typename = space.type(w_self).getname(space)
- raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'target')
+ raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'target')
return space.wrap(w_self.target)
def AugAssign_set_target(space, w_self, w_new_value):
@@ -3415,8 +3396,7 @@
if w_obj is not None:
return w_obj
if not w_self.initialization_state & 8:
- typename = space.type(w_self).getname(space)
- raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'op')
+ raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'op')
return operator_to_class[w_self.op - 1]()
def AugAssign_set_op(space, w_self, w_new_value):
@@ -3439,8 +3419,7 @@
if w_obj is not None:
return w_obj
if not w_self.initialization_state & 16:
- typename = space.type(w_self).getname(space)
- raise operationerrfmt(space.w_AttributeError, "'%s' object has no attribute '%s'", typename, 'value')
+ raise operationerrfmt(space.w_AttributeError, "'%T' object has no attribute '%s'", w_self, 'value')
return space.wrap(w_self.value)
def AugAssign_set_value(space, w_self, w_new_value):
@@ -3489,8 +3468,7 @@
More information about the pypy-commit
mailing list