[pypy-commit] pypy reflex-support: open up more tests (from test_datatypes.py) for use with dummy backend

2014-05-01 Thread wlav
Author: Wim Lavrijsen wlavrij...@lbl.gov
Branch: reflex-support
Changeset: r71123:49432e9dce27
Date: 2014-04-30 23:45 -0700
http://bitbucket.org/pypy/pypy/changeset/49432e9dce27/

Log:open up more tests (from test_datatypes.py) for use with dummy
backend

diff --git a/pypy/module/cppyy/src/dummy_backend.cxx 
b/pypy/module/cppyy/src/dummy_backend.cxx
--- a/pypy/module/cppyy/src/dummy_backend.cxx
+++ b/pypy/module/cppyy/src/dummy_backend.cxx
@@ -8,15 +8,18 @@
 #include vector
 
 #include assert.h
+#include stddef.h
 #include stdlib.h
 #include string.h
 
+#pragma GCC diagnostic ignored -Winvalid-offsetof
 
 // add example01.cxx code
 int globalAddOneToInt(int a);
 
 namespace dummy {
 #include example01.cxx
+#include datatypes.cxx
 }
 
 int globalAddOneToInt(int a) {
@@ -36,7 +39,7 @@
const std::vectorstd::string argtypes,
const std::string returntype,
EMethodType mtype = kNormal) :
-   m_name(name), m_argtypes(argtypes), m_returntype(returntype), 
m_type(mtype) {}
+m_name(name), m_argtypes(argtypes), m_returntype(returntype), 
m_type(mtype) {}
 
 std::string m_name;
 std::vectorstd::string m_argtypes;
@@ -44,14 +47,28 @@
 EMethodType m_type;
 };
 
+struct Cppyy_PseudoDatambrInfo {
+Cppyy_PseudoDatambrInfo(const std::string name,
+const std::string type,
+size_t offset, bool isstatic) :
+m_name(name), m_type(type), m_offset(offset), m_isstatic(isstatic) {}
+
+std::string m_name;
+std::string m_type;
+size_t m_offset;
+bool m_isstatic;
+};
+
 struct Cppyy_PseudoClassInfo {
 Cppyy_PseudoClassInfo() {}
 Cppyy_PseudoClassInfo(const std::vectorCppyy_PseudoMethodInfo methods,
- long method_offset) :
-m_methods(methods), m_method_offset(method_offset) {}
+  long method_offset,
+  const std::vectorCppyy_PseudoDatambrInfo data) :
+m_methods(methods), m_method_offset(method_offset), m_datambrs(data) {}
 
 std::vectorCppyy_PseudoMethodInfo m_methods;
 long m_method_offset;
+std::vectorCppyy_PseudoDatambrInfo m_datambrs;
 };
 
 typedef std::mapcppyy_scope_t, Cppyy_PseudoClassInfo Scopes_t;
@@ -59,10 +76,57 @@
 
 static std::mapstd::string, long s_methods;
 
+#define PUBLIC_CPPYY_DATA(dmname, dmtype) \
+data.push_back(Cppyy_PseudoDatambrInfo(m_#dmname, #dmtype,  \
+offsetof(dummy::cppyy_test_data, m_##dmname), false));\
+argtypes.clear(); \
+methods.push_back(Cppyy_PseudoMethodInfo( \
+ get_#dmname, argtypes, #dmtype));  \
+s_methods[cppyy_test_data::get_#dmname] = s_method_id++;\
+argtypes.push_back(#dmtype);  \
+methods.push_back(Cppyy_PseudoMethodInfo( \
+ set_#dmname, argtypes, void));   \
+s_methods[cppyy_test_data::set_#dmname] = s_method_id++;\
+argtypes.clear(); \
+argtypes.push_back(const #dmtype);   \
+methods.push_back(Cppyy_PseudoMethodInfo( \
+ set_#dmname_c, argtypes, void));   \
+s_methods[cppyy_test_data::set_#dmname_c] = s_method_id++
+
+#define PUBLIC_CPPYY_DATA2(dmname, dmtype)\
+PUBLIC_CPPYY_DATA(dmname, dmtype);\
+data.push_back(Cppyy_PseudoDatambrInfo(m_#dmname_array, #dmtype[5], \
+offsetof(dummy::cppyy_test_data, m_##dmname##_array), false));\
+data.push_back(Cppyy_PseudoDatambrInfo(m_#dmname_array2, #dmtype*,  \
+offsetof(dummy::cppyy_test_data, m_##dmname##_array2), false));   \
+argtypes.clear(); \
+methods.push_back(Cppyy_PseudoMethodInfo( \
+ get_#dmname_array, argtypes, #dmtype*));   \
+s_methods[cppyy_test_data::get_#dmname_array] = s_method_id++;\
+methods.push_back(Cppyy_PseudoMethodInfo( \
+ get_#dmname_array2, argtypes, #dmtype*));  \
+s_methods[cppyy_test_data::get_#dmname_array2] = s_method_id++
+
+#define PUBLIC_CPPYY_DATA3(dmname, dmtype, key)   \
+PUBLIC_CPPYY_DATA2(dmname, dmtype);   \
+argtypes.push_back(#dmtype*);   \
+methods.push_back(Cppyy_PseudoMethodInfo( \
+ 

[pypy-commit] pypy reflex-support: save indices separately to make this slightly more maintainable

2014-05-01 Thread wlav
Author: Wim Lavrijsen wlavrij...@lbl.gov
Branch: reflex-support
Changeset: r71121:3d8b31186b6f
Date: 2014-04-30 17:07 -0700
http://bitbucket.org/pypy/pypy/changeset/3d8b31186b6f/

Log:save indices separately to make this slightly more maintainable

diff --git a/pypy/module/cppyy/src/dummy_backend.cxx 
b/pypy/module/cppyy/src/dummy_backend.cxx
--- a/pypy/module/cppyy/src/dummy_backend.cxx
+++ b/pypy/module/cppyy/src/dummy_backend.cxx
@@ -4,12 +4,14 @@
 #include map
 #include string
 #include sstream
+#include utility
 #include vector
 
 #include assert.h
 #include stdlib.h
 #include string.h
 
+
 // add example01.cxx code
 int globalAddOneToInt(int a);
 
@@ -27,143 +29,162 @@
 typedef std::mapstd::string, cppyy_scope_t  Handles_t;
 static Handles_t s_handles;
 
+enum EMethodType { kNormal=0, kConstructor=1, kStatic=2 };
+
 struct Cppyy_PseudoMethodInfo {
 Cppyy_PseudoMethodInfo(const std::string name,
const std::vectorstd::string argtypes,
-   const std::string returntype) :
-m_name(name), m_argtypes(argtypes), m_returntype(returntype) {}
+   const std::string returntype,
+   EMethodType mtype = kNormal) :
+   m_name(name), m_argtypes(argtypes), m_returntype(returntype), 
m_type(mtype) {}
 
 std::string m_name;
 std::vectorstd::string m_argtypes;
 std::string m_returntype;
+EMethodType m_type;
 };
 
 struct Cppyy_PseudoClassInfo {
 Cppyy_PseudoClassInfo() {}
-Cppyy_PseudoClassInfo(const std::vectorCppyy_PseudoMethodInfo methods) :
-m_methods(methods ) {}
+Cppyy_PseudoClassInfo(const std::vectorCppyy_PseudoMethodInfo methods,
+ long method_offset) :
+m_methods(methods), m_method_offset(method_offset) {}
 
 std::vectorCppyy_PseudoMethodInfo m_methods;
+long m_method_offset;
 };
 
 typedef std::mapcppyy_scope_t, Cppyy_PseudoClassInfo Scopes_t;
 static Scopes_t s_scopes;
 
-static int example01_last_static_method = 0;
-static int example01_last_constructor = 0;
-static int payload_methods_offset = 0;
+static std::mapstd::string, long s_methods;
 
 struct Cppyy_InitPseudoReflectionInfo {
 Cppyy_InitPseudoReflectionInfo() {
 // class example01 --
 static long s_scope_id = 0;
+static long s_method_id = 0;
 
 { // class example01 --
 s_handles[example01] = (cppyy_scope_t)++s_scope_id;
 
 std::vectorCppyy_PseudoMethodInfo methods;
 
-// ( 0) static double staticAddToDouble(double a)
+// static double staticAddToDouble(double a)
 std::vectorstd::string argtypes;
 argtypes.push_back(double);
-methods.push_back(Cppyy_PseudoMethodInfo(staticAddToDouble, 
argtypes, double));
+methods.push_back(Cppyy_PseudoMethodInfo(staticAddToDouble, 
argtypes, double, kStatic));
+s_methods[static_example01::staticAddToDouble_double] = 
s_method_id++;
 
-// ( 1) static int staticAddOneToInt(int a)
-// ( 2) static int staticAddOneToInt(int a, int b)
+// static int staticAddOneToInt(int a)
+// static int staticAddOneToInt(int a, int b)
 argtypes.clear();
 argtypes.push_back(int);
-methods.push_back(Cppyy_PseudoMethodInfo(staticAddOneToInt, 
argtypes, int));
+methods.push_back(Cppyy_PseudoMethodInfo(staticAddOneToInt, 
argtypes, int, kStatic));
+s_methods[static_example01::staticAddOneToInt_int] = s_method_id++;
 argtypes.push_back(int);
-methods.push_back(Cppyy_PseudoMethodInfo(staticAddOneToInt, 
argtypes, int));
+methods.push_back(Cppyy_PseudoMethodInfo(staticAddOneToInt, 
argtypes, int, kStatic));
+s_methods[static_example01::staticAddOneToInt_int_int] = 
s_method_id++;
 
-// ( 3) static int staticAtoi(const char* str)
+// static int staticAtoi(const char* str)
 argtypes.clear();
 argtypes.push_back(const char*);
-methods.push_back(Cppyy_PseudoMethodInfo(staticAtoi, argtypes, 
int));
+methods.push_back(Cppyy_PseudoMethodInfo(staticAtoi, argtypes, 
int, kStatic));
+s_methods[static_example01::staticAtoi_cchar*] = s_method_id++;
 
-// ( 4) static char* staticStrcpy(const char* strin)
-methods.push_back(Cppyy_PseudoMethodInfo(staticStrcpy, argtypes, 
char*));
+// static char* staticStrcpy(const char* strin)
+methods.push_back(Cppyy_PseudoMethodInfo(staticStrcpy, argtypes, 
char*, kStatic));
+s_methods[static_example01::staticStrcpy_cchar*] = s_method_id++;
 
-// ( 5) static void staticSetPayload(payload* p, double d)
-// ( 6) static payload* staticCyclePayload(payload* p, double d)
-// ( 7) static payload staticCopyCyclePayload(payload* p, double d)
+// static void staticSetPayload(payload* p, double d)
+// static payload* staticCyclePayload(payload* p, double d)
+// static payload 

[pypy-commit] pypy reflex-support: clean and refactoring of methods and class creation

2014-05-01 Thread wlav
Author: Wim Lavrijsen wlavrij...@lbl.gov
Branch: reflex-support
Changeset: r71118:af753187637f
Date: 2014-04-29 11:41 -0700
http://bitbucket.org/pypy/pypy/changeset/af753187637f/

Log:clean and refactoring of methods and class creation

diff --git a/pypy/module/cppyy/__init__.py b/pypy/module/cppyy/__init__.py
--- a/pypy/module/cppyy/__init__.py
+++ b/pypy/module/cppyy/__init__.py
@@ -16,7 +16,7 @@
 '_register_class': 'interp_cppyy.register_class',
 '_is_static' : 'interp_cppyy.is_static',
 '_get_nullptr'   : 'interp_cppyy.get_nullptr',
-'CPPInstance': 'interp_cppyy.W_CPPInstance',
+'CPPInstanceBase': 'interp_cppyy.W_CPPInstance',
 'addressof'  : 'interp_cppyy.addressof',
 'bind_object': 'interp_cppyy.bind_object',
 }
@@ -25,7 +25,7 @@
 '_init_pythonify': 'pythonify._init_pythonify',
 'load_reflection_info'   : 'pythonify.load_reflection_info',
 'add_pythonization'  : 'pythonify.add_pythonization',
-'Template'   : 'pythonify.CppyyTemplateType',
+'Template'   : 'pythonify.CPPTemplate',
 }
 
 def __init__(self, space, *args):
diff --git a/pypy/module/cppyy/interp_cppyy.py 
b/pypy/module/cppyy/interp_cppyy.py
--- a/pypy/module/cppyy/interp_cppyy.py
+++ b/pypy/module/cppyy/interp_cppyy.py
@@ -155,8 +155,7 @@
 the memory_regulator.
 
 _attrs_ = ['space', 'scope', 'index', 'cppmethod', 'arg_defs', 
'args_required',
-   'args_expected', 'converters', 'executor', '_funcaddr', 
'cif_descr',
-   'uses_local']
+   'converters', 'executor', '_funcaddr', 'cif_descr', 
'uses_local']
 _immutable_ = True
 
 def __init__(self, space, containing_scope, method_index, arg_defs, 
args_required):
@@ -166,7 +165,6 @@
 self.cppmethod = capi.c_get_method(self.space, self.scope, 
method_index)
 self.arg_defs = arg_defs
 self.args_required = args_required
-self.args_expected = len(arg_defs)
 
 # Setup of the method dispatch's innards is done lazily, i.e. only when
 # the method is actually used.
@@ -183,6 +181,12 @@
 loc_idx = lltype.direct_ptradd(rffi.cast(rffi.CCHARP, call_local), 
idx*stride)
 return rffi.cast(rffi.VOIDP, loc_idx)
 
+def call_w(self, w_cppinstance, args_w):
+cppinstance = self.space.interp_w(W_CPPInstance, w_cppinstance, 
can_be_None=False)
+cppinstance._nullcheck()
+cppthis = cppinstance.get_cppthis(self.scope)
+return self.call(cppthis, args_w)
+
 @jit.unroll_safe
 def call(self, cppthis, args_w):
 assert lltype.typeOf(cppthis) == capi.C_OBJECT
@@ -277,7 +281,7 @@
 funcaddr = methgetter(rffi.cast(capi.C_OBJECT, cppthis))
 self._funcaddr = rffi.cast(rffi.VOIDP, funcaddr)
 
-nargs = self.args_expected + 1   # +1: cppthis
+nargs = len(self.arg_defs) + 1   # +1: cppthis
 
 # memory block for CIF description (note: not tracked as the 
life
 # time of methods is normally the duration of the application)
@@ -335,7 +339,7 @@
 
 # extra
 cif_descr.abi = clibffi.FFI_DEFAULT_ABI
-cif_descr.nargs = self.args_expected + 1 # +1: cppthis
+cif_descr.nargs = len(self.arg_defs) + 1 # +1: cppthis
 
 res = jit_libffi.jit_ffi_prep_cif(cif_descr)
 if res != clibffi.FFI_OK:
@@ -405,21 +409,21 @@
 
 
 class CPPFunction(CPPMethod):
-Global (namespaced) function dispatcher. For now, the base class has
-all the needed functionality, by allowing the C++ this pointer to be null
-in the call. An optimization is expected there, however.
+Global (namespaced) function dispatcher.
 
 _immutable_ = True
 
+def call_w(self, w_cppinstance, args_w):
+return CPPMethod.call(self, capi.C_NULL_OBJECT, args_w)
+
 def __repr__(self):
 return CPPFunction: %s % self.signature()
 
 
 class CPPTemplatedCall(CPPMethod):
-Method dispatcher that first needs to resolve the template instance.
-Note that the derivation is from object: the CPPMethod is a data member.
+Method dispatcher that first resolves the template instance.
 
-_attrs_ = ['space', 'templ_args', 'method']
+_attrs_ = ['space', 'templ_args']
 _immutable_ = True
 
 def __init__(self, space, templ_args, containing_scope, method_index, 
arg_defs, args_required):
@@ -456,22 +460,17 @@
 
 _immutable_ = True
 
-def call(self, cppthis, args_w):
+def call_w(self, w_cppinstance, args_w):
 # TODO: these casts are very, very un-pretty; need to find a way of
 # re-using CPPMethod's features w/o these roundabouts
 vscope = rffi.cast(capi.C_OBJECT, self.scope.handle)
-cppinstance = 

[pypy-commit] pypy reflex-support: refactoring/cleanup

2014-05-01 Thread wlav
Author: Wim Lavrijsen wlavrij...@lbl.gov
Branch: reflex-support
Changeset: r71119:0eff3fae1c87
Date: 2014-04-30 10:54 -0700
http://bitbucket.org/pypy/pypy/changeset/0eff3fae1c87/

Log:refactoring/cleanup

diff --git a/pypy/module/cppyy/interp_cppyy.py 
b/pypy/module/cppyy/interp_cppyy.py
--- a/pypy/module/cppyy/interp_cppyy.py
+++ b/pypy/module/cppyy/interp_cppyy.py
@@ -158,9 +158,9 @@
'converters', 'executor', '_funcaddr', 'cif_descr', 
'uses_local']
 _immutable_ = True
 
-def __init__(self, space, containing_scope, method_index, arg_defs, 
args_required):
+def __init__(self, space, declaring_scope, method_index, arg_defs, 
args_required):
 self.space = space
-self.scope = containing_scope
+self.scope = declaring_scope
 self.index = method_index
 self.cppmethod = capi.c_get_method(self.space, self.scope, 
method_index)
 self.arg_defs = arg_defs
@@ -174,6 +174,12 @@
 self._funcaddr = lltype.nullptr(rffi.VOIDP.TO)
 self.uses_local = False
 
+@staticmethod
+def unpack_cppthis(space, w_cppinstance, declaring_scope):
+cppinstance = space.interp_w(W_CPPInstance, w_cppinstance, 
can_be_None=False)
+cppinstance._nullcheck()
+return cppinstance.get_cppthis(declaring_scope)
+
 def _address_from_local_buffer(self, call_local, idx):
 if not call_local:
 return call_local
@@ -181,12 +187,6 @@
 loc_idx = lltype.direct_ptradd(rffi.cast(rffi.CCHARP, call_local), 
idx*stride)
 return rffi.cast(rffi.VOIDP, loc_idx)
 
-def call_w(self, w_cppinstance, args_w):
-cppinstance = self.space.interp_w(W_CPPInstance, w_cppinstance, 
can_be_None=False)
-cppinstance._nullcheck()
-cppthis = cppinstance.get_cppthis(self.scope)
-return self.call(cppthis, args_w)
-
 @jit.unroll_safe
 def call(self, cppthis, args_w):
 assert lltype.typeOf(cppthis) == capi.C_OBJECT
@@ -413,8 +413,9 @@
 
 _immutable_ = True
 
-def call_w(self, w_cppinstance, args_w):
-return CPPMethod.call(self, capi.C_NULL_OBJECT, args_w)
+@staticmethod
+def unpack_cppthis(space, w_cppinstance, declaring_scope):
+return capi.C_NULL_OBJECT
 
 def __repr__(self):
 return CPPFunction: %s % self.signature()
@@ -426,11 +427,11 @@
 _attrs_ = ['space', 'templ_args']
 _immutable_ = True
 
-def __init__(self, space, templ_args, containing_scope, method_index, 
arg_defs, args_required):
+def __init__(self, space, templ_args, declaring_scope, method_index, 
arg_defs, args_required):
 self.space = space
 self.templ_args = templ_args
 # TODO: might have to specialize for CPPTemplatedCall on 
CPPMethod/CPPFunction here
-CPPMethod.__init__(self, space, containing_scope, method_index, 
arg_defs, args_required)
+CPPMethod.__init__(self, space, declaring_scope, method_index, 
arg_defs, args_required)
 
 def call(self, cppthis, args_w):
 assert lltype.typeOf(cppthis) == capi.C_OBJECT
@@ -460,19 +461,15 @@
 
 _immutable_ = True
 
-def call_w(self, w_cppinstance, args_w):
-# TODO: these casts are very, very un-pretty; need to find a way of
-# re-using CPPMethod's features w/o these roundabouts
-vscope = rffi.cast(capi.C_OBJECT, self.scope.handle)
-cppinstance = self.space.interp_w(W_CPPInstance, w_cppinstance, 
can_be_None=True)
-w_result = CPPMethod.call(self, vscope, args_w)
-newthis = rffi.cast(capi.C_OBJECT, self.space.int_w(w_result))
-if cppinstance is not None:
-cppinstance._rawobject = newthis
-memory_regulator.register(cppinstance)
-return w_cppinstance
-return wrap_cppobject(self.space, newthis, self.scope,
-  do_cast=False, python_owns=True, fresh=True)
+@staticmethod
+def unpack_cppthis(space, w_cppinstance, declaring_scope):
+return rffi.cast(capi.C_OBJECT, declaring_scope.handle)
+
+def call(self, cppthis, args_w):
+# Note: this does not return a wrapped instance, just a pointer to the
+# new instance; the overload must still wrap it before returning. Also,
+# cppthis is declaring_scope.handle (as per unpack_cppthis(), above).
+return CPPMethod.call(self, cppthis, args_w)
 
 def __repr__(self):
 return CPPConstructor: %s % self.signature()
@@ -501,12 +498,12 @@
 collection of (possibly) overloaded methods or functions. It calls these
 in order and deals with error handling and reporting.
 
-_attrs_ = ['space', 'scope', 'functions']
-_immutable_fields_ = ['scope', 'functions[*]']
+_attrs_ = ['space', 'functions']
+_immutable_fields_ = ['functions[*]']
 
-def __init__(self, space, containing_scope, functions):
+def __init__(self, space, declaring_scope, functions):
 self.space = space
-self.scope = 

[pypy-commit] pypy reflex-support: merge default into branch

2014-05-01 Thread wlav
Author: Wim Lavrijsen wlavrij...@lbl.gov
Branch: reflex-support
Changeset: r71117:3fb585ce5d69
Date: 2014-04-28 15:25 -0700
http://bitbucket.org/pypy/pypy/changeset/3fb585ce5d69/

Log:merge default into branch

diff --git a/dotviewer/graphserver.py b/dotviewer/graphserver.py
--- a/dotviewer/graphserver.py
+++ b/dotviewer/graphserver.py
@@ -160,15 +160,14 @@
  | instructions in dotviewer/sshgraphserver.py\n)
 try:
 import pygame
-except ImportError:
+if isinstance(e, pygame.error):
+print  f, help
+except Exception, e:
 f.seek(0)
 f.truncate()
-print  f, ImportError
+print  f, %s: %s % (e.__class__.__name__, e)
 print  f,  | Pygame is not installed; either install it, or
 print  f, help
-else:
-if isinstance(e, pygame.error):
-print  f, help
 io.sendmsg(msgstruct.MSG_ERROR, f.getvalue())
 else:
 listen_server(sys.argv[1])
diff --git a/pypy/doc/getting-started.rst b/pypy/doc/getting-started.rst
--- a/pypy/doc/getting-started.rst
+++ b/pypy/doc/getting-started.rst
@@ -76,7 +76,7 @@
 .. code-block:: console
 
 $ curl -O http://python-distribute.org/distribute_setup.py
-$ curl -O https://raw.github.com/pypa/pip/master/contrib/get-pip.py
+$ curl -O 
https://raw.githubusercontent.com/pypa/pip/master/contrib/get-pip.py
 $ ./pypy-2.1/bin/pypy distribute_setup.py
 $ ./pypy-2.1/bin/pypy get-pip.py
 $ ./pypy-2.1/bin/pip install pygments  # for example
diff --git a/pypy/doc/release-2.3.0.rst b/pypy/doc/release-2.3.0.rst
--- a/pypy/doc/release-2.3.0.rst
+++ b/pypy/doc/release-2.3.0.rst
@@ -1,11 +1,17 @@
 ===
-PyPy 2.3 -  TODO
+PyPy 2.3 - Easier Than Ever
 ===
 
 We're pleased to announce PyPy 2.3, which targets version 2.7.6 of the Python
 language. This release updates the stdlib from 2.7.3, jumping directly to 
2.7.6.
 
-This release also contains several bugfixes and performance improvements. 
+This release also contains several bugfixes and performance improvements,
+many generated by real users finding corner cases our `TDD`_ methods missed. 
+`CFFI`_ has made it easier than ever to use existing C code with both cpython
+and PyPy, easing the transition for packages like `cryptography`_, `Pillow`_ 
+(Python Imaging Library [Fork]), a basic port of `pygame-cffi`_, and others. 
+
+PyPy can now be embedded in a hosting application, for instance inside `uWSGI`_
 
 You can download the PyPy 2.3 release here:
 
@@ -17,72 +23,112 @@
 Please consider donating more so we can finish those projects!  The three
 projects are:
 
-* Py3k (supporting Python 3.x): the release PyPy3 2.2 is imminent.
+* `Py3k`_ (supporting Python 3.x): the release PyPy3 2.2 is imminent.
 
-* STM (software transactional memory): a preview will be released very soon,
-  as soon as we fix a few bugs
+* `STM`_ (software transactional memory): a preview will be released very soon,
+  once we fix a few bugs
 
-* NumPy: the work done is included in the PyPy 2.2 release. More details below.
+* `NumPy`_ the work done is included in the PyPy 2.2 release. More details 
below.
 
-.. _`Raspberry Pi Foundation`: http://www.raspberrypi.org
+.. _`Py3k`: http://pypy.org/py3donate.html
+.. _`STM`: http://pypy.org/tmdonate2.html
+.. _ `Numpy`: http://pypy.org/numpydonate.html
+.. _`TDD`: http://doc.pypy.org/en/latest/how-to-contribute.html
+.. _`CFFI`: http://cffi.readthedocs.org
+.. _`cryptography`: https://cryptography.io
+.. _`Pillow`: https://pypi.python.org/pypi/Pillow/2.4.0
+.. _`pygame-cffi`: https://github.com/CTPUG/pygame_cffi
+.. _`uWSGI`: http://uwsgi-docs.readthedocs.org/en/latest/PyPy.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.2 and cpython 2.7.2`_ performance comparison)
+CPython 2.7. It's fast (`pypy 2.2 and cpython 2.7.2`_ performance comparison;
+note that the latest cpython is not faster than cpython 2.7.2)
 due to its integrated tracing JIT compiler.
 
-This release supports x86 machines running Linux 32/64, Mac OS X 64, Windows
-32, or ARM (ARMv6 or ARMv7, with VFPv3).
+This release supports x86 machines running Linux 32/64, Mac OS X 64, Windows,
+and OpenBSD,
+as well as newer ARM hardware (ARMv6 or ARMv7, with VFPv3) running Linux. 
 
-Work on the native Windows 64 is still stalling, we would welcome a volunteer
-to handle that.
+While we support 32 bit python on Windows, work on the native Windows 64
+bit python is still stalling, we would welcome a volunteer
+to `handle that`_.
 
 .. _`pypy 2.2 and cpython 2.7.2`: http://speed.pypy.org
+.. _`handle that`: 
http://doc.pypy.org/en/latest/windows.html#what-is-missing-for-a-full-64-bit-translation
 
 Highlights
 

[pypy-commit] pypy reflex-support: fix warning message

2014-05-01 Thread wlav
Author: Wim Lavrijsen wlavrij...@lbl.gov
Branch: reflex-support
Changeset: r71122:ba929dab8b1f
Date: 2014-04-30 17:24 -0700
http://bitbucket.org/pypy/pypy/changeset/ba929dab8b1f/

Log:fix warning message

diff --git a/pypy/module/cppyy/test/datatypes.h 
b/pypy/module/cppyy/test/datatypes.h
--- a/pypy/module/cppyy/test/datatypes.h
+++ b/pypy/module/cppyy/test/datatypes.h
@@ -16,9 +16,9 @@
 class four_vector {
 public:
 four_vector(double x, double y, double z, double t) :
-m_x(x), m_y(y), m_z(z), m_t(t), m_cc_called(false) {}
+m_cc_called(false), m_x(x), m_y(y), m_z(z), m_t(t) {}
 four_vector(const four_vector s) :
-m_x(s.m_x), m_y(s.m_y), m_z(s.m_z), m_t(s.m_t), m_cc_called(true) {}
+m_cc_called(true), m_x(s.m_x), m_y(s.m_y), m_z(s.m_z), m_t(s.m_t) {}
 
 double operator[](int i) {
if (i == 0) return m_x;
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy reflex-support: updates for CINT backend after refactoring

2014-05-01 Thread wlav
Author: Wim Lavrijsen wlavrij...@lbl.gov
Branch: reflex-support
Changeset: r71120:544dc4a17124
Date: 2014-04-30 13:51 -0700
http://bitbucket.org/pypy/pypy/changeset/544dc4a17124/

Log:updates for CINT backend after refactoring

diff --git a/pypy/module/cppyy/capi/cint_capi.py 
b/pypy/module/cppyy/capi/cint_capi.py
--- a/pypy/module/cppyy/capi/cint_capi.py
+++ b/pypy/module/cppyy/capi/cint_capi.py
@@ -127,19 +127,18 @@
 argc = len(args_w)
 
 try:
-# Note: argcount is +1 for the class (== w_self)
-if argc  5 or 6  argc:
+if argc  4 or 5  argc:
 raise TypeError(wrong number of arguments)
 
-# second argument must be a name
-funcname = space.str_w(args_w[1])
+# first argument must be a name
+funcname = space.str_w(args_w[0])
 
 # last (optional) argument is number of parameters
 npar = 0
-if argc == 6: npar = space.int_w(args_w[5])
+if argc == 5: npar = space.int_w(args_w[4])
 
-# third argument must be a callable python object
-w_callable = args_w[2]
+# second argument must be a callable python object
+w_callable = args_w[1]
 if not space.is_true(space.callable(w_callable)):
 raise TypeError(2nd argument is not a valid python callable)
 
@@ -159,17 +158,21 @@
 # so far, so good; leaves on issue: CINT is expecting a wrapper, but
 # we need the overload that takes a function pointer, which is not in
 # the dictionary, hence this helper:
-newinst = _create_tf1(space.str_w(args_w[1]), funcaddr,
-  space.float_w(args_w[3]), space.float_w(args_w[4]), npar)
- 
-from pypy.module.cppyy import interp_cppyy
-w_instance = interp_cppyy.wrap_cppobject(space, newinst, tf1_class,
-  do_cast=False, python_owns=True, 
fresh=True)
+newinst = _create_tf1(space.str_w(args_w[0]), funcaddr,
+  space.float_w(args_w[2]), space.float_w(args_w[3]), npar)
+
+# w_self is a null-ptr bound as TF1 
+from pypy.module.cppyy.interp_cppyy import W_CPPInstance, 
memory_regulator
+cppself = space.interp_w(W_CPPInstance, w_self, can_be_None=False)
+cppself._rawobject = newinst
+memory_regulator.register(cppself)
 
 # tie all the life times to the TF1 instance
-space.setattr(w_instance, space.wrap('_callback'), w_callback)
+space.setattr(w_self, space.wrap('_callback'), w_callback)
 
-return w_instance
+# by definition for __init__
+return None
+
 except (OperationError, TypeError, IndexError), e:
 newargs_w = args_w[1:] # drop class
 
@@ -312,7 +315,7 @@
 
 # location
 w_address = space.call_method(w_leaf, GetValuePointer)
-buf = space.buffer_w(w_address)
+buf = space.getarg_w('s*', w_address)
 from pypy.module._rawffi import buffer
 assert isinstance(buf, buffer.RawFFIBuffer)
 address = rffi.cast(rffi.CCHARP, buf.datainstance.ll_buffer)
@@ -395,7 +398,7 @@
 _method_alias(space, w_pycppclass, __len__, GetSize)
 
 elif name == TF1:
-space.setattr(w_pycppclass, space.wrap(__new__), 
_pythonizations[tf1_tf1])
+space.setattr(w_pycppclass, space.wrap(__init__), 
_pythonizations[tf1_tf1])
 
 elif name == TFile:
 _method_alias(space, w_pycppclass, __getattr__, Get)
diff --git a/pypy/module/cppyy/interp_cppyy.py 
b/pypy/module/cppyy/interp_cppyy.py
--- a/pypy/module/cppyy/interp_cppyy.py
+++ b/pypy/module/cppyy/interp_cppyy.py
@@ -933,7 +933,7 @@
 self.datamembers[datamember_name] = datamember
 
 def construct(self):
-self.get_overload(self.name).call(None, [])
+return self.get_overload(self.name).call(None, [])
 
 def find_overload(self, name):
 raise self.missing_attribute_error(name)
diff --git a/pypy/module/cppyy/test/test_cint.py 
b/pypy/module/cppyy/test/test_cint.py
--- a/pypy/module/cppyy/test/test_cint.py
+++ b/pypy/module/cppyy/test/test_cint.py
@@ -435,14 +435,16 @@
 
 class AppTestCINTFUNCTION:
 spaceconfig = dict(usemodules=['cppyy', '_rawffi', 'itertools'])
+_pypytest_leaks = None   # TODO: figure out the false positives
 
 # test the function callbacks; this does not work with Reflex, as it can
 # not generate functions on the fly (it might with cffi?)
 
+@py.test.mark.dont_track_allocations(TODO: understand; initialization 
left-over?)
 def test01_global_function_callback(self):
 Test callback of a python global function
 
-import cppyy
+import cppyy, gc
 TF1 = cppyy.gbl.TF1
 
 def identity(x):
@@ -460,11 +462,12 @@
 assert f.Eval(0.5) == 0.5
 
 del f  # force here, to prevent leak-check complaints
+gc.collect()
 
 def test02_callable_object_callback(self):
 Test callback of a python callable object
 
- 

[pypy-commit] pypy default: Test and fix (according to -A)

2014-05-01 Thread arigo
Author: Armin Rigo ar...@tunes.org
Branch: 
Changeset: r71127:5fc41bfef56f
Date: 2014-05-01 09:31 +0200
http://bitbucket.org/pypy/pypy/changeset/5fc41bfef56f/

Log:Test and fix (according to -A)

diff --git a/pypy/module/_lsprof/interp_lsprof.py 
b/pypy/module/_lsprof/interp_lsprof.py
--- a/pypy/module/_lsprof/interp_lsprof.py
+++ b/pypy/module/_lsprof/interp_lsprof.py
@@ -204,20 +204,20 @@
 name = '?'
 if class_name is None:
 class_name = w_type.getname(space)# if the rest doesn't work
-return {method '%s' of '%s' objects} % (name, class_name)
+return method '%s' of '%s' objects % (name, class_name)
 
 
 def create_spec_for_function(space, w_func):
 if w_func.w_module is not None:
 module = space.str_w(w_func.w_module)
 if module != '__builtin__':
-return '{%s.%s}' % (module, w_func.name)
-return '{%s}' % w_func.name
+return '%s.%s' % (module, w_func.name)
+return '%s' % w_func.name
 
 
 def create_spec_for_object(space, w_obj):
 class_name = space.type(w_obj).getname(space)
-return {'%s' object} % (class_name,)
+return '%s' object % (class_name,)
 
 
 def create_spec(space, w_arg):
diff --git a/pypy/module/_lsprof/test/test_cprofile.py 
b/pypy/module/_lsprof/test/test_cprofile.py
--- a/pypy/module/_lsprof/test/test_cprofile.py
+++ b/pypy/module/_lsprof/test/test_cprofile.py
@@ -11,6 +11,22 @@
 import _lsprof
 assert repr(_lsprof.Profiler) == type '_lsprof.Profiler'
 
+def test_builtins(self):
+import _lsprof
+prof = _lsprof.Profiler()
+lst = []
+prof.enable()
+lst.append(len(lst))
+prof.disable()
+stats = prof.getstats()
+expected = (
+len,
+method 'append' of 'list' objects,
+method 'disable' of '_lsprof.Profiler' objects,
+)
+for entry in stats:
+assert entry.code in expected
+
 def test_direct(self):
 import _lsprof
 def getticks():
@@ -37,10 +53,8 @@
 stats = prof.getstats()
 entries = {}
 for entry in stats:
-if not hasattr(entry.code, 'co_name'):
-print entry.code
-else:
-entries[entry.code.co_name] = entry
+assert hasattr(entry.code, 'co_name')
+entries[entry.code.co_name] = entry
 efoo = entries['foo']
 assert efoo.callcount == 2
 assert efoo.reccallcount == 1
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] extradoc extradoc: shared-nothing draft

2014-05-01 Thread Raemi
Author: Remi Meier remi.me...@gmail.com
Branch: extradoc
Changeset: r5206:2ad9a98221dd
Date: 2014-05-01 10:39 +0200
http://bitbucket.org/pypy/extradoc/changeset/2ad9a98221dd/

Log:shared-nothing draft

diff --git a/talk/icooolps2014/position-paper.tex 
b/talk/icooolps2014/position-paper.tex
--- a/talk/icooolps2014/position-paper.tex
+++ b/talk/icooolps2014/position-paper.tex
@@ -229,9 +229,34 @@
 
 \subsubsection{Shared-Nothing / multiple processes}
 
-- often needs major restructuring of programs (explicit data exchange)\\
-- sometimes communication overhead is too large\\
-- shared memory is a problem, copies of memory are too expensive
+There are also approaches that work around the GIL instead of trying
+to replace it. If an application can be split into completely
+independent parts that only very rarely need to share anything, or
+only do so via an external program like a database, then it is
+sensible to have one GIL per independent part. As an example of such
+an approach we look at the
+\emph{multiprocessing}\footnote{https://docs.python.org/2/library/multiprocessing.html}
+module of Python. In essence, it uses process-forking to provide the
+application with multiple interpreters that can run in parallel.
+Communication is then done explicitly through pipes.
+
+Obviously not every application fits well into this model and its
+applicability is therefore quite limited. Performance is good as
+long as the application does not need to communicate a lot, because
+inter-process communication is relatively expensive. Also the
+implementation of this approach is very cheap since one can
+actually take an unmodfied GIL-supported interpreter and run
+multiple of them in parallel. That way, we also inherit the
+easy integration of external libraries without any changes.
+While the model of explicit communication is often seen as a
+superior way to synchronize concurrent applications because
+of its explicitness, it does not actually introduce a better
+synchronization mechanism for applications.
+
+
+%% - often needs major restructuring of programs (explicit data exchange)\\
+%% - sometimes communication overhead is too large\\
+%% - shared memory is a problem, copies of memory are too expensive
 
 \subsubsection{Transactional Memory}
 \paragraph{HTM}
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] extradoc extradoc: TM draft

2014-05-01 Thread Raemi
Author: Remi Meier remi.me...@gmail.com
Branch: extradoc
Changeset: r5207:89a404ccd022
Date: 2014-05-01 11:35 +0200
http://bitbucket.org/pypy/extradoc/changeset/89a404ccd022/

Log:TM draft

diff --git a/talk/icooolps2014/position-paper.tex 
b/talk/icooolps2014/position-paper.tex
--- a/talk/icooolps2014/position-paper.tex
+++ b/talk/icooolps2014/position-paper.tex
@@ -134,11 +134,14 @@
 multi-threading in the interpreter. The basic guarantee is that the
 GIL may only be released in-between bytecode instructions. The
 interpreter can thus rely on complete isolation and atomicity of these
-instructions. As a consequence, applications can rely on certain
-operations to be atomic. While this is probably not a good idea,
-it is used in practice. A solution replacing the GIL should therefore
-uphold these guarantees, while preferably also be as easily
-implementable as a GIL for the interpreter.
+instructions. Additionally, it provides the application with a
+sequential consistency model. As a consequence, applications can rely
+on certain operations to be atomic and that they will always be
+executed in the order in which they appear in the code. While
+depending on this may not always be a good idea, it is done in
+practice. A solution replacing the GIL should therefore uphold these
+guarantees, while preferably also be as easily implementable as a GIL
+for the interpreter.
 [xxx mention that the interpreter is typically very large and maintained
 by open-source communities]
 
@@ -253,24 +256,86 @@
 of its explicitness, it does not actually introduce a better
 synchronization mechanism for applications.
 
-
 %% - often needs major restructuring of programs (explicit data exchange)\\
 %% - sometimes communication overhead is too large\\
 %% - shared memory is a problem, copies of memory are too expensive
 
+
 \subsubsection{Transactional Memory}
+Transactional memory (TM) can be used as a direct replacement for a
+single global lock. Transactions provide the same atomicity and
+isolation guarantees as the GIL provides for the execution of bytecode
+instructions. So instead of acquiring and releasing the GIL between
+these instructions, this approach runs the protected instructions
+inside transactions.
+
+TM can be implemented in software (STM) or in hardware (HTM. There are
+also some hybrid approaches that combine the two. We count these
+hybrid approaches as STM, since they usually provide the same
+capabilities as software-only approaches but with different
+performance characteristics. We will now first look at HTM that
+recently gained a lot of popularity by its introduction in common
+desktop CPUs from Intel (Haswell generation).
+
 \paragraph{HTM}
 
-- false-sharing on cache-line level\\
-- limited capacity (caches, undocumented)\\
-- random aborts (haswell)\\
-- generally: transaction-length limited (no atomic blocks)
+HTM provides us with transactions like any TM system does. It can
+be used as a direct replacement for the GIL. However, as is common
+with hardware-only solutions, there are quite a few limitations
+that can not be lifted easily. For this comparison, we look at
+the implementation of Intel in recent Haswell generation CPUs.
+
+HTM in these CPUs works on the level of caches. This has a few
+consequences like false-sharing on the cache-line level, and most
+importantly it limits the amount of memory that can be accessed within
+a transaction. This transaction-length limitation makes it necessary
+to have a fallback in place in case this limit is reached. In recent
+attempts, the usual fallback is the GIL (XXX: cite). The current
+generation of HTM hits this limit very often for our use case (XXX:
+cite ruby GIL paper) and therefore does not parallelize that well.
+
+The performance of HTM is pretty good (XXX: cite again...) as it does
+not introduce much overhead. And it can transparently parallelize
+existing applications to some degree. The implementation is very
+straight-forward because it directly replaces the GIL in a central
+place. HTM is also directly compatible with any external library that
+needs to be integrated and synchronized for use in multiple
+threads. The one thing that is missing is support for a better
+synchronization mechanism for the application. It is not possible
+in general to expose the hardware-transactions to the application
+in the form of atomic blocks because that would require much
+longer transactions. 
+
+%% - false-sharing on cache-line level\\
+%% - limited capacity (caches, undocumented)\\
+%% - random aborts (haswell)\\
+%% - generally: transaction-length limited (no atomic blocks)
 
 \paragraph{STM}
 
-- overhead (100-1000\%) (barrier reference resolution, kills performance on 
low \#cpu)
-(FastLane: low overhead, not much gain)\\
-- unlimited transaction length (easy atomic blocks)
+STM provides all the same benefits as HTM except for its performance.
+It is not unusual for the overhead introduced by STM to be between
+100\% to even 1000\%. 

[pypy-commit] extradoc extradoc: add some handwavy comparison table

2014-05-01 Thread Raemi
Author: Remi Meier remi.me...@gmail.com
Branch: extradoc
Changeset: r5208:f1d159462e0a
Date: 2014-05-01 12:14 +0200
http://bitbucket.org/pypy/extradoc/changeset/f1d159462e0a/

Log:add some handwavy comparison table

diff --git a/talk/icooolps2014/position-paper.tex 
b/talk/icooolps2014/position-paper.tex
--- a/talk/icooolps2014/position-paper.tex
+++ b/talk/icooolps2014/position-paper.tex
@@ -9,7 +9,7 @@
 % authoryearTo obtain author/year citation style instead of numeric.
 
 \usepackage[utf8]{inputenc}
-
+\usepackage{array}
 \usepackage{amsmath}
 
 
@@ -338,6 +338,31 @@
 %% - unlimited transaction length (easy atomic blocks)
 
 \section{The Way Forward}
+\begin{table}[]
+  \centering
+  \begin{tabular}{|p{2cm}|c|c|c|c|c|}
+\hline
+ \textbf{GIL}  \parbox[t]{1cm}{\textbf{Fine-grained locking}}
+ \parbox[t]{1cm}{\textbf{Shared-nothing}}  \textbf{HTM}  \textbf{STM}\\
+\hline
+Performance 0   +   +++   -{-} \\
+\hline
+Existing applications   ++  ++  -{-}  ++  ++   \\
+\hline
+Better synchronization  0   0   - -   ++   \\
+\hline
+Implementation  ++  -   ++++  ++   \\
+\hline
+External libraries  ++  ++  ++++  ++   \\
+\hline
+  \end{tabular}
+  \caption{Comparison (--/-/0/+/++)}
+  \label{tab:comparison}
+\end{table}
+
+Comparison in Table \ref{tab:comparison}
+
+
 possible solution:\\
 - use virtual memory paging to somehow lower the STM overhead\\
 - tight integration with GC and jit?
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: More tweaks: pass a (w_func, w_type) pair to the elidable function

2014-05-01 Thread arigo
Author: Armin Rigo ar...@tunes.org
Branch: 
Changeset: r71128:3f23bbb810db
Date: 2014-05-01 11:16 +0200
http://bitbucket.org/pypy/pypy/changeset/3f23bbb810db/

Log:More tweaks: pass a (w_func, w_type) pair to the elidable function
instead of a string, and make the function @elidable_promote as it
should be what we want anyway. Use a new small container,
W_DelayedBuiltinStr; see docstring.

diff --git a/pypy/module/_lsprof/interp_lsprof.py 
b/pypy/module/_lsprof/interp_lsprof.py
--- a/pypy/module/_lsprof/interp_lsprof.py
+++ b/pypy/module/_lsprof/interp_lsprof.py
@@ -59,7 +59,7 @@
 self.tt, self.it, calls_repr))
 
 def get_code(self, space):
-return self.frame
+return returns_code(space, self.frame)
 
 W_StatsEntry.typedef = TypeDef(
 'StatsEntry',
@@ -86,7 +86,7 @@
 frame_repr, self.callcount, self.reccallcount, self.tt, self.it))
 
 def get_code(self, space):
-return self.frame
+return returns_code(space, self.frame)
 
 W_StatsSubEntry.typedef = TypeDef(
 'SubStatsEntry',
@@ -215,18 +215,55 @@
 return '%s' % w_func.name
 
 
-def create_spec_for_object(space, w_obj):
-class_name = space.type(w_obj).getname(space)
+def create_spec_for_object(space, w_type):
+class_name = w_type.getname(space)
 return '%s' object % (class_name,)
 
 
-def create_spec(space, w_arg):
+class W_DelayedBuiltinStr(W_Root):
+# This class should not be seen at app-level, but is useful to
+# contain a (w_func, w_type) pair returned by prepare_spec().
+# Turning this pair into a string cannot be done eagerly in
+# an @elidable function because of space.str_w(), but it can
+# be done lazily when we really want it.
+
+_immutable_fields_ = ['w_func', 'w_type']
+
+def __init__(self, w_func, w_type):
+self.w_func = w_func
+self.w_type = w_type
+self.w_string = None
+
+def wrap_string(self, space):
+if self.w_string is None:
+if self.w_type is None:
+s = create_spec_for_function(space, self.w_func)
+elif self.w_func is None:
+s = create_spec_for_object(space, self.w_type)
+else:
+s = create_spec_for_method(space, self.w_func, self.w_type)
+self.w_string = space.wrap(s)
+return self.w_string
+
+W_DelayedBuiltinStr.typedef = TypeDef(
+'DelayedBuiltinStr',
+__str__ = interp2app(W_DelayedBuiltinStr.wrap_string),
+)
+
+def returns_code(space, w_frame):
+if isinstance(w_frame, W_DelayedBuiltinStr):
+return w_frame.wrap_string(space)
+return w_frame# actually a PyCode object
+
+
+def prepare_spec(w_arg):
 if isinstance(w_arg, Method):
-return create_spec_for_method(space, w_arg.w_function, w_arg.w_class)
+return (w_arg.w_function, w_arg.w_class)
 elif isinstance(w_arg, Function):
-return create_spec_for_function(space, w_arg)
+return (w_arg, None)
 else:
-return create_spec_for_object(space, w_arg)
+return (None, space.type(w_arg))
+prepare_spec._always_inline_ = True
 
 
 def lsprof_call(space, w_self, frame, event, w_arg):
@@ -239,12 +276,10 @@
 w_self._enter_return(code)
 elif event == 'c_call':
 if w_self.builtins:
-key = create_spec(space, w_arg)
-w_self._enter_builtin_call(key)
+w_self._enter_builtin_call(w_arg)
 elif event == 'c_return' or event == 'c_exception':
 if w_self.builtins:
-key = create_spec(space, w_arg)
-w_self._enter_builtin_return(key)
+w_self._enter_builtin_return(w_arg)
 else:
 # ignore or raise an exception???
 pass
@@ -307,13 +342,14 @@
 return entry
 raise
 
-@jit.elidable
-def _get_or_make_builtin_entry(self, key, make=True):
+@jit.elidable_promote()
+def _get_or_make_builtin_entry(self, w_func, w_type, make):
+key = (w_func, w_type)
 try:
 return self.builtin_data[key]
 except KeyError:
 if make:
-entry = ProfilerEntry(self.space.wrap(key))
+entry = ProfilerEntry(W_DelayedBuiltinStr(w_func, w_type))
 self.builtin_data[key] = entry
 return entry
 raise
@@ -337,20 +373,18 @@
 context._stop(self, entry)
 self.current_context = context.previous
 
-def _enter_builtin_call(self, key):
-self = jit.promote(self)
-key = jit.promote_string(key)
-entry = self._get_or_make_builtin_entry(key)
+def _enter_builtin_call(self, w_arg):
+w_func, w_type = prepare_spec(w_arg)
+entry = self._get_or_make_builtin_entry(w_func, w_type, True)
 self.current_context = ProfilerContext(self, entry)
 
-def _enter_builtin_return(self, key):
+def _enter_builtin_return(self, w_arg):
 context = 

[pypy-commit] pypy default: Translation fixes

2014-05-01 Thread arigo
Author: Armin Rigo ar...@tunes.org
Branch: 
Changeset: r71129:75f2886305e0
Date: 2014-05-01 12:04 +0200
http://bitbucket.org/pypy/pypy/changeset/75f2886305e0/

Log:Translation fixes

diff --git a/pypy/module/_lsprof/interp_lsprof.py 
b/pypy/module/_lsprof/interp_lsprof.py
--- a/pypy/module/_lsprof/interp_lsprof.py
+++ b/pypy/module/_lsprof/interp_lsprof.py
@@ -208,6 +208,7 @@
 
 
 def create_spec_for_function(space, w_func):
+assert isinstance(w_func, Function)
 if w_func.w_module is not None:
 module = space.str_w(w_func.w_module)
 if module != '__builtin__':
@@ -256,7 +257,7 @@
 return w_frame# actually a PyCode object
 
 
-def prepare_spec(w_arg):
+def prepare_spec(space, w_arg):
 if isinstance(w_arg, Method):
 return (w_arg.w_function, w_arg.w_class)
 elif isinstance(w_arg, Function):
@@ -374,7 +375,7 @@
 self.current_context = context.previous
 
 def _enter_builtin_call(self, w_arg):
-w_func, w_type = prepare_spec(w_arg)
+w_func, w_type = prepare_spec(self.space, w_arg)
 entry = self._get_or_make_builtin_entry(w_func, w_type, True)
 self.current_context = ProfilerContext(self, entry)
 
@@ -382,7 +383,7 @@
 context = self.current_context
 if context is None:
 return
-w_func, w_type = prepare_spec(w_arg)
+w_func, w_type = prepare_spec(self.space, w_arg)
 try:
 entry = self._get_or_make_builtin_entry(w_func, w_type, False)
 except KeyError:
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Reintroduce definite crashes when using @elidable in a way that cannot be satisfied.

2014-05-01 Thread arigo
Author: Armin Rigo ar...@tunes.org
Branch: 
Changeset: r71130:350eca4d9a9d
Date: 2014-05-01 13:41 +0200
http://bitbucket.org/pypy/pypy/changeset/350eca4d9a9d/

Log:Reintroduce definite crashes when using @elidable in a way that
cannot be satisfied.

diff --git a/rpython/jit/codewriter/call.py b/rpython/jit/codewriter/call.py
--- a/rpython/jit/codewriter/call.py
+++ b/rpython/jit/codewriter/call.py
@@ -266,14 +266,14 @@
 # check that the result is really as expected
 if loopinvariant:
 if extraeffect != EffectInfo.EF_LOOPINVARIANT:
-from rpython.jit.codewriter.policy import log; log.WARNING(
+raise Exception(
 in operation %r: this calls a _jit_loop_invariant_ function,
  but this contradicts other sources (e.g. it can have random
  effects): EF=%s % (op, extraeffect))
 if elidable:
 if extraeffect not in (EffectInfo.EF_ELIDABLE_CANNOT_RAISE,
EffectInfo.EF_ELIDABLE_CAN_RAISE):
-from rpython.jit.codewriter.policy import log; log.WARNING(
+raise Exception(
 in operation %r: this calls an _elidable_function_,
  but this contradicts other sources (e.g. it can have random
  effects): EF=%s % (op, extraeffect))
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Add a pypy-c test for issue #1328

2014-05-01 Thread arigo
Author: Armin Rigo ar...@tunes.org
Branch: 
Changeset: r71131:c7196a03a054
Date: 2014-05-01 14:05 +0200
http://bitbucket.org/pypy/pypy/changeset/c7196a03a054/

Log:Add a pypy-c test for issue #1328

diff --git a/pypy/module/pypyjit/test_pypy_c/test_cprofile.py 
b/pypy/module/pypyjit/test_pypy_c/test_cprofile.py
new file mode 100644
--- /dev/null
+++ b/pypy/module/pypyjit/test_pypy_c/test_cprofile.py
@@ -0,0 +1,31 @@
+import py
+from pypy.module.pypyjit.test_pypy_c.test_00_model import BaseTestPyPyC
+
+class TestCProfile(BaseTestPyPyC):
+
+def test_cprofile_builtin(self):
+def main(n):
+import _lsprof
+prof = _lsprof.Profiler()
+i = 0
+lst = []
+prof.enable()
+while i  n:
+lst.append(i)   # ID: append
+lst.pop()   # ID: pop
+i += 1
+prof.disable()
+return [(entry.code, entry.callcount) for entry in prof.getstats()]
+#
+log = self.run(main, [500])
+assert sorted(log.result) == [
+({method 'append' of 'list' objects}, 500),
+({method 'disable' of '_lsprof.Profiler' objects}, 1),
+({method 'pop' of 'list' objects}, 500),
+]
+for method in ['append', 'pop']:
+loop, = log.loops_by_id(method)
+print loop.ops_by_id(method)
+assert 'call(' not in repr(loop.ops_by_id(method))
+assert 'call_may_force(' not in repr(loop.ops_by_id(method))
+assert 'call_cond(' in repr(loop.ops_by_id(method))
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] cffi default: issue #156: _Bool type already included in VS2013

2014-05-01 Thread taewookk
Author: Taewook Kang twk...@gmail.com
Branch: 
Changeset: r1509:d993a73f4d60
Date: 2014-05-01 20:27 +0900
http://bitbucket.org/cffi/cffi/changeset/d993a73f4d60/

Log:issue #156: _Bool type already included in VS2013

diff --git a/c/misc_win32.h b/c/misc_win32.h
--- a/c/misc_win32.h
+++ b/c/misc_win32.h
@@ -222,7 +222,9 @@
 typedef unsigned __int16 uint16_t;
 typedef unsigned __int32 uint32_t;
 typedef unsigned __int64 uint64_t;
+#if !defined(_MSC_VER) || _MSC_VER = 1700
 typedef unsigned char _Bool;
+#endif
 
 
 //
diff --git a/cffi/vengine_cpy.py b/cffi/vengine_cpy.py
--- a/cffi/vengine_cpy.py
+++ b/cffi/vengine_cpy.py
@@ -780,7 +780,9 @@
 typedef unsigned __int16 uint16_t;
 typedef unsigned __int32 uint32_t;
 typedef unsigned __int64 uint64_t;
+#if !defined(_MSC_VER) || _MSC_VER = 1700
 typedef unsigned char _Bool;
+#endif
 #else
 #if (defined (__SVR4)  defined (__sun)) || defined(_AIX)
 #  include alloca.h
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix the test

2014-05-01 Thread arigo
Author: Armin Rigo ar...@tunes.org
Branch: 
Changeset: r71132:caee1b15d940
Date: 2014-05-01 14:20 +0200
http://bitbucket.org/pypy/pypy/changeset/caee1b15d940/

Log:fix the test

diff --git a/pypy/module/pypyjit/test_pypy_c/test_cprofile.py 
b/pypy/module/pypyjit/test_pypy_c/test_cprofile.py
--- a/pypy/module/pypyjit/test_pypy_c/test_cprofile.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_cprofile.py
@@ -19,13 +19,13 @@
 #
 log = self.run(main, [500])
 assert sorted(log.result) == [
-({method 'append' of 'list' objects}, 500),
-({method 'disable' of '_lsprof.Profiler' objects}, 1),
-({method 'pop' of 'list' objects}, 500),
+(method 'append' of 'list' objects, 500),
+(method 'disable' of '_lsprof.Profiler' objects, 1),
+(method 'pop' of 'list' objects, 500),
 ]
 for method in ['append', 'pop']:
 loop, = log.loops_by_id(method)
 print loop.ops_by_id(method)
-assert 'call(' not in repr(loop.ops_by_id(method))
-assert 'call_may_force(' not in repr(loop.ops_by_id(method))
-assert 'call_cond(' in repr(loop.ops_by_id(method))
+assert ' call(' not in repr(loop.ops_by_id(method))
+assert ' call_may_force(' not in repr(loop.ops_by_id(method))
+assert ' cond_call(' in repr(loop.ops_by_id(method))
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] extradoc extradoc: more text; corrections

2014-05-01 Thread Raemi
Author: Remi Meier remi.me...@gmail.com
Branch: extradoc
Changeset: r5209:98a3ff04f14b
Date: 2014-05-01 14:25 +0200
http://bitbucket.org/pypy/extradoc/changeset/98a3ff04f14b/

Log:more text; corrections

diff --git a/talk/icooolps2014/position-paper.tex 
b/talk/icooolps2014/position-paper.tex
--- a/talk/icooolps2014/position-paper.tex
+++ b/talk/icooolps2014/position-paper.tex
@@ -69,14 +69,14 @@
 have a problem. While there is certainly a lot of popularity around
 languages like Python and Ruby, their ability to make use of multiple
 cores is somewhat limited. For ease of implementation they chose to
-use a single, global interpreter lock (GIL) to synchronize the
+use a single, global interpreter lock (GIL) to synchronise the
 execution of code in multiple threads. While this is a
-straight-forward way to eliminate synchronization issues in the
+straight-forward way to eliminate synchronisation issues in the
 interpreter, it prevents parallel execution. Code executed in multiple
-threads will be serialized over this GIL so that only one thread can
+threads will be serialised over this GIL so that only one thread can
 execute at a time.
 
-There exist several solutions and work-arounds to remove or avoid the
+There exist several solutions and workarounds to remove or avoid the
 GIL in order to benefit from multiple cores. We are going to discuss
 several of them and try to find the best way forward. The first
 approach uses fine-grained locking to replace the single GIL. Then
@@ -96,7 +96,7 @@
 These requirements are not easy to meet. We argue that STM is the
 overall winner. While it has a big performance problem currently, it
 gets more points in all the other categories. We think that it is the
-only solution that also provides a better synchronization mechanism to
+only solution that also provides a better synchronisation mechanism to
 the application in the form of atomic blocks.
 
 %% \subsection{Issue}
@@ -124,13 +124,13 @@
 \section{Discussion}
 
 \paragraph{dynamic language VM problems}
-
+XXX:
 - high allocation rate (short lived objects)\\
 - (don't know anything about the program that runs until it actually runs: 
arbitrary atomic block size)
 
 
 \subsection{Why is there a GIL?}
-The GIL is a very simple synchronization mechanism for supporting
+The GIL is a very simple synchronisation mechanism for supporting
 multi-threading in the interpreter. The basic guarantee is that the
 GIL may only be released in-between bytecode instructions. The
 interpreter can thus rely on complete isolation and atomicity of these
@@ -151,7 +151,7 @@
 thread-safe can voluntarily release the GIL themselves in order to
 still provide some parallelism. This is done for example for
 potentially long I/O operations. Consequently, I/O-bound,
-multi-threaded applications can actually parallelize to some
+multi-threaded applications can actually parallelise to some
 degree. Again, a potential solution should be able to integrate with
 external libraries with similar ease. We will however focus our
 argumentation more on running code in the interpreted language in
@@ -159,21 +159,21 @@
 
 Since the GIL is mostly an implementation detail of the interpreter,
 it is not exposed to the application running on top of it. To
-synchronize memory accesses in applications using threads, the
+synchronise memory accesses in applications using threads, the
 state-of-the-art still means explicit locking everywhere. It is well
-known that using locks for synchronization is not easy.  They are
+known that using locks for synchronisation is not easy.  They are
 non-composable, have overhead, may deadlock, limit scalability, and
 overall add a lot of complexity. For a better parallel programming
 model for dynamic languages, we propose another, well-known
-synchronization mechanism called \emph{atomic blocks}.
+synchronisation mechanism called \emph{atomic blocks}.
 
 Atomic blocks are composable, deadlock-free, higher-level and expose
 useful atomicity and isolation guarantees to the application for a
-series of instructions.  Interpreters using using a GIL can simply
-guarantee that the GIL is not released during the execution of the
-atomic block. Of course, this still means that no two atomic blocks
-can execute in parallel or even concurrently. Potential solutions
-that provide a good way to implement atomic blocks are therefore
+series of instructions.  Interpreters using a GIL can simply guarantee
+that the GIL is not released during the execution of the atomic
+block. Of course, this still means that no two atomic blocks can
+execute in parallel or even concurrently. Potential solutions that
+provide a good way to implement atomic blocks are therefore
 preferable.
 
 
@@ -188,9 +188,9 @@
 \item[Performance:] How well does the approach perform compared to the
   GIL on single and multiple threads?
 \item[Existing applications:] How big are the changes required to
-  integrate with and parallelize existing applications?

[pypy-commit] extradoc extradoc: say what we are working on

2014-05-01 Thread Raemi
Author: Remi Meier remi.me...@gmail.com
Branch: extradoc
Changeset: r5210:d66a59f8ecf2
Date: 2014-05-01 15:20 +0200
http://bitbucket.org/pypy/extradoc/changeset/d66a59f8ecf2/

Log:say what we are working on

diff --git a/talk/icooolps2014/position-paper.tex 
b/talk/icooolps2014/position-paper.tex
--- a/talk/icooolps2014/position-paper.tex
+++ b/talk/icooolps2014/position-paper.tex
@@ -146,7 +146,7 @@
 by open-source communities]
 
 The GIL also allows for easy integration with external C libraries that
-do not need to be thread-safe. For the duration of the calls, we
+may not be thread-safe. For the duration of the calls, we
 simply do not release the GIL. External libraries that are explicitly
 thread-safe can voluntarily release the GIL themselves in order to
 still provide some parallelism. This is done for example for
@@ -269,11 +269,11 @@
 these instructions, this approach runs the protected instructions
 inside transactions.
 
-TM can be implemented in software (STM) or in hardware (HTM. There are
-also some hybrid approaches that combine the two. We count these
+TM can be implemented in software (STM) or in hardware (HTM). There
+are also hybrid approaches, which combine the two. We count these
 hybrid approaches as STM, since they usually provide the same
 capabilities as software-only approaches but with different
-performance characteristics. We will now first look at HTM that
+performance characteristics. We will now first look at HTM, which
 recently gained a lot of popularity by its introduction in common
 desktop CPUs from Intel (Haswell generation).
 
@@ -368,21 +368,27 @@
 Following the above argumentation for each approach we assembled a
 general overview in Table \ref{tab:comparison}. The general picture is
 everything else than clear. It looks like HTM may be a good solution
-to replace the GIL in the future. Current implementations are however
-far too limiting and do not provide good scaling.
+to replace the GIL in the near future. Current implementations are
+however far too limiting and do not provide good scaling.
 
-Just allowing for parallel execution only means that dynamic languages
+Allowing for parallel execution just means that dynamic languages
 catch up to all other languages that already provide real
 parallelism. This is why we think that only the STM approach is a
 viable solution in the long-term. It provides the application with a
 simple memory model (sequential consistency) and a composable way to
 synchronise memory accesses using atomic blocks.
 
-STM has a big performance problem. We believe that further work
-to reduce the overhead by closely working together with the
-hardware should be the focus of research. Hybrid approaches that
-combine STM and HTM for performance may be able to overcome this
-obstacle.
+Unfortunately, STM has a big performance problem. One way to approach
+this problem is to make STM systems that use the available hardware
+better. We are currently working on a STM system that makes use of
+several hardware features like virtual memory and memory segmentation.
+We further tailor the system to the discussed use case which gives us
+an advantage over other STM systems that are more general.  With this
+approach, initial results suggest that we can keep the overhead of STM
+already below 50\%. A hybrid TM system, which also uses HTM to
+accelerate certain tasks, looks like a very promising direction of
+research too. In general we believe that further work to reduce the
+overhead of STM is very worthwhile.
 
 
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Fix, maybe? Hard to reproduce

2014-05-01 Thread arigo
Author: Armin Rigo ar...@tunes.org
Branch: 
Changeset: r71134:fc40700d203d
Date: 2014-05-01 16:33 +0200
http://bitbucket.org/pypy/pypy/changeset/fc40700d203d/

Log:Fix, maybe? Hard to reproduce

diff --git a/rpython/translator/c/test/test_newgc.py 
b/rpython/translator/c/test/test_newgc.py
--- a/rpython/translator/c/test/test_newgc.py
+++ b/rpython/translator/c/test/test_newgc.py
@@ -1123,6 +1123,8 @@
 #
 fd1 = os.open(filename1, os.O_WRONLY | os.O_CREAT, 0666)
 fd2 = os.open(filename2, os.O_WRONLY | os.O_CREAT, 0666)
+# try to ensure we get twice the exact same output below
+gc.collect(); gc.collect(); gc.collect()
 rgc.dump_rpy_heap(fd1)
 rgc.dump_rpy_heap(fd2)  # try twice in a row
 keepalive_until_here(s2)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Change the Makefile for asmgcc: instead of a lot of separate rules,

2014-05-01 Thread arigo
Author: Armin Rigo ar...@tunes.org
Branch: 
Changeset: r71133:d0edc0e21b53
Date: 2014-05-01 16:15 +0200
http://bitbucket.org/pypy/pypy/changeset/d0edc0e21b53/

Log:Change the Makefile for asmgcc: instead of a lot of separate rules,
have one rule that contains all the steps needed to turn a %.c into
a %.o (and not a %.lbl.s, which should reduce a lot the time taken
by the final linking step).

diff --git a/rpython/translator/c/genc.py b/rpython/translator/c/genc.py
--- a/rpython/translator/c/genc.py
+++ b/rpython/translator/c/genc.py
@@ -421,24 +421,12 @@
 
 #XXX: this conditional part is not tested at all
 if self.config.translation.gcrootfinder == 'asmgcc':
-trackgcfiles = [cfile[:cfile.rfind('.')] for cfile in mk.cfiles]
 if self.translator.platform.name == 'msvc':
-trackgcfiles = [f for f in trackgcfiles
-if f.startswith(('implement', 'testing',
- '../module_cache/module'))]
-sfiles = ['%s.s' % (c,) for c in trackgcfiles]
-lblsfiles = ['%s.lbl.s' % (c,) for c in trackgcfiles]
-gcmapfiles = ['%s.gcmap' % (c,) for c in trackgcfiles]
-mk.definition('ASMFILES', sfiles)
-mk.definition('ASMLBLFILES', lblsfiles)
-mk.definition('GCMAPFILES', gcmapfiles)
-if self.translator.platform.name == 'msvc':
-mk.definition('DEBUGFLAGS', '-MD -Zi')
+raise Exception(msvc no longer supports asmgcc)
+if self.config.translation.shared:
+mk.definition('DEBUGFLAGS', '-O2 -fomit-frame-pointer -g 
-fPIC')
 else:
-if self.config.translation.shared:
-mk.definition('DEBUGFLAGS', '-O2 -fomit-frame-pointer -g 
-fPIC')
-else:
-mk.definition('DEBUGFLAGS', '-O2 -fomit-frame-pointer -g')
+mk.definition('DEBUGFLAGS', '-O2 -fomit-frame-pointer -g')
 
 if self.config.translation.shared:
 mk.definition('PYPY_MAIN_FUNCTION', pypy_main_startup)
@@ -447,46 +435,28 @@
 
 mk.definition('PYTHON', get_recent_cpython_executable())
 
-if self.translator.platform.name == 'msvc':
-lblofiles = []
-for cfile in mk.cfiles:
-f = cfile[:cfile.rfind('.')]
-if f in trackgcfiles:
-ofile = '%s.lbl.obj' % (f,)
-else:
-ofile = '%s.obj' % (f,)
+mk.definition('GCMAPFILES', '$(subst .c,.gcmap,$(SOURCES))')
+mk.definition('OBJECTS1', '$(subst .c,.o,$(SOURCES))')
+mk.definition('OBJECTS', '$(OBJECTS1) gcmaptable.s')
 
-lblofiles.append(ofile)
-mk.definition('ASMLBLOBJFILES', lblofiles)
-mk.definition('OBJECTS', 'gcmaptable.obj $(ASMLBLOBJFILES)')
-# /Oi (enable intrinsics) and /Ob1 (some inlining) are 
mandatory
-# even in debug builds
-mk.definition('ASM_CFLAGS', '$(CFLAGS) $(CFLAGSEXTRA) /Oi 
/Ob1')
-mk.rule('.SUFFIXES', '.s', [])
-mk.rule('.s.obj', '',
-'cmd /c $(MASM) /nologo /Cx /Cp /Zm /coff /Fo$@ /c $ 
$(INCLUDEDIRS)')
-mk.rule('.c.gcmap', '',
-['$(CC) /nologo $(ASM_CFLAGS) /c /FAs /Fa$*.s $ 
$(INCLUDEDIRS)',
- 'cmd /c $(PYTHON) 
$(RPYDIR)/translator/c/gcc/trackgcroot.py -fmsvc -t $*.s  $@']
-)
-mk.rule('gcmaptable.c', '$(GCMAPFILES)',
-'cmd /c $(PYTHON) 
$(RPYDIR)/translator/c/gcc/trackgcroot.py -fmsvc $(GCMAPFILES)  $@')
+# the rule that transforms %.c into %.o, by compiling it to
+# %.s, then applying trackgcroot to get %.lbl.s and %.gcmap, and
+# finally by using the assembler ($(CC) again for now) to get %.o
+mk.rule('%.o %.gcmap', '%.c', [
+'$(CC) $(CFLAGS) $(CFLAGSEXTRA) -frandom-seed=$ '
+'-o $*.s -S $ $(INCLUDEDIRS)',
+'$(PYTHON) $(RPYDIR)/translator/c/gcc/trackgcroot.py '
+'-t $*.s  $*.gctmp',
+'$(CC) -o $*.o -c $*.lbl.s',
+'mv $*.gctmp $*.gcmap',
+'rm $*.s $*.lbl.s'])
 
-else:
-mk.definition('OBJECTS', '$(ASMLBLFILES) gcmaptable.s')
-mk.rule('%.s', '%.c', '$(CC) $(CFLAGS) $(CFLAGSEXTRA) 
-frandom-seed=$ -o $@ -S $ $(INCLUDEDIRS)')
-mk.rule('%.s', '%.cxx', '$(CXX) $(CFLAGS) $(CFLAGSEXTRA) 
-frandom-seed=$ -o $@ -S $ $(INCLUDEDIRS)')
-mk.rule('%.lbl.s %.gcmap', '%.s',
-[
- '$(PYTHON) 
$(RPYDIR)/translator/c/gcc/trackgcroot.py '
- '-t 

[pypy-commit] pypy default: some gcc 4.9 support

2014-05-01 Thread arigo
Author: Armin Rigo ar...@tunes.org
Branch: 
Changeset: r71135:dea725674dbe
Date: 2014-05-01 16:44 +0200
http://bitbucket.org/pypy/pypy/changeset/dea725674dbe/

Log:some gcc 4.9 support

diff --git a/rpython/translator/c/gcc/trackgcroot.py 
b/rpython/translator/c/gcc/trackgcroot.py
--- a/rpython/translator/c/gcc/trackgcroot.py
+++ b/rpython/translator/c/gcc/trackgcroot.py
@@ -522,6 +522,8 @@
 'movnt', 'mfence', 'lfence', 'sfence',
 # bit manipulations
 'bextr',
+# invalid instruction
+'ud2',
 ])
 
 # a partial list is hopefully good enough for now; it's all to support
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Redo 3f8b9a32c444, this time more conservatively: try to constant-fold

2014-05-01 Thread arigo
Author: Armin Rigo ar...@tunes.org
Branch: 
Changeset: r71136:c8e9da1478dc
Date: 2014-05-01 17:01 +0200
http://bitbucket.org/pypy/pypy/changeset/c8e9da1478dc/

Log:Redo 3f8b9a32c444, this time more conservatively: try to constant-
fold the CALL_PURE operation from *both* rewrite.py and pure.py.

diff --git a/rpython/jit/metainterp/optimizeopt/optimizer.py 
b/rpython/jit/metainterp/optimizeopt/optimizer.py
--- a/rpython/jit/metainterp/optimizeopt/optimizer.py
+++ b/rpython/jit/metainterp/optimizeopt/optimizer.py
@@ -347,6 +347,21 @@
 def forget_numberings(self, box):
 self.optimizer.forget_numberings(box)
 
+def _can_optimize_call_pure(self, op):
+arg_consts = []
+for i in range(op.numargs()):
+arg = op.getarg(i)
+const = self.get_constant_box(arg)
+if const is None:
+return None
+arg_consts.append(const)
+else:
+# all constant arguments: check if we already know the result
+try:
+return self.optimizer.call_pure_results[arg_consts]
+except KeyError:
+return None
+
 
 class Optimizer(Optimization):
 
diff --git a/rpython/jit/metainterp/optimizeopt/pure.py 
b/rpython/jit/metainterp/optimizeopt/pure.py
--- a/rpython/jit/metainterp/optimizeopt/pure.py
+++ b/rpython/jit/metainterp/optimizeopt/pure.py
@@ -57,6 +57,16 @@
 self.emit_operation(nextop)
 
 def optimize_CALL_PURE(self, op):
+# Step 1: check if all arguments are constant
+result = self._can_optimize_call_pure(op)
+if result is not None:
+# this removes a CALL_PURE with all constant arguments.
+self.make_constant(op.result, result)
+self.last_emitted_operation = REMOVED
+return
+
+# Step 2: check if all arguments are the same as a previous
+# CALL_PURE.
 args = self.optimizer.make_args_key(op)
 oldop = self.pure_operations.get(args, None)
 if oldop is not None and oldop.getdescr() is op.getdescr():
diff --git a/rpython/jit/metainterp/optimizeopt/rewrite.py 
b/rpython/jit/metainterp/optimizeopt/rewrite.py
--- a/rpython/jit/metainterp/optimizeopt/rewrite.py
+++ b/rpython/jit/metainterp/optimizeopt/rewrite.py
@@ -516,24 +516,13 @@
 return False
 
 def optimize_CALL_PURE(self, op):
-arg_consts = []
-for i in range(op.numargs()):
-arg = op.getarg(i)
-const = self.get_constant_box(arg)
-if const is None:
-break
-arg_consts.append(const)
-else:
-# all constant arguments: check if we already know the result
-try:
-result = self.optimizer.call_pure_results[arg_consts]
-except KeyError:
-pass
-else:
-# this removes a CALL_PURE with all constant arguments.
-self.make_constant(op.result, result)
-self.last_emitted_operation = REMOVED
-return
+# this removes a CALL_PURE with all constant arguments.
+# Note that it's also done in pure.py.  For now we need both...
+result = self._can_optimize_call_pure(op)
+if result is not None:
+self.make_constant(op.result, result)
+self.last_emitted_operation = REMOVED
+return
 self.emit_operation(op)
 
 def optimize_GUARD_NO_EXCEPTION(self, op):
diff --git a/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py 
b/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py
--- a/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py
+++ b/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py
@@ -5164,7 +5164,6 @@
 self.optimize_strunicode_loop(ops, expected)
 
 def test_call_pure_vstring_const(self):
-py.test.skip(implement me)
 ops = 
 []
 p0 = newstr(3)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix whatsnew

2014-05-01 Thread bdkearns
Author: Brian Kearns bdkea...@gmail.com
Branch: 
Changeset: r71137:643e652b0b55
Date: 2014-05-01 11:22 -0400
http://bitbucket.org/pypy/pypy/changeset/643e652b0b55/

Log:fix whatsnew

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
@@ -5,4 +5,4 @@
 .. this is a revision shortly after release-2.3.x
 .. startrev: 0524dae88c75
 
-
+.. branch: reflex-support
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Actually, ud2 is unreachable, not ignored.

2014-05-01 Thread arigo
Author: Armin Rigo ar...@tunes.org
Branch: 
Changeset: r71138:95d8506f3861
Date: 2014-05-01 17:28 +0200
http://bitbucket.org/pypy/pypy/changeset/95d8506f3861/

Log:Actually, ud2 is unreachable, not ignored.

diff --git a/rpython/translator/c/gcc/trackgcroot.py 
b/rpython/translator/c/gcc/trackgcroot.py
--- a/rpython/translator/c/gcc/trackgcroot.py
+++ b/rpython/translator/c/gcc/trackgcroot.py
@@ -522,8 +522,6 @@
 'movnt', 'mfence', 'lfence', 'sfence',
 # bit manipulations
 'bextr',
-# invalid instruction
-'ud2',
 ])
 
 # a partial list is hopefully good enough for now; it's all to support
@@ -695,6 +693,9 @@
 return self.visit_ret(line)
 return []
 
+def visit_ud2(self, line):
+return InsnStop(ud2)# unreachable instruction
+
 def visit_jmp(self, line):
 tablelabels = []
 match = self.r_jmp_switch.match(line)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy issue1430: clean up test

2014-05-01 Thread mattip
Author: mattip matti.pi...@gmail.com
Branch: issue1430
Changeset: r71139:91e137303927
Date: 2014-05-01 19:39 +0300
http://bitbucket.org/pypy/pypy/changeset/91e137303927/

Log:clean up test

diff --git a/rpython/rlib/test/test_rsocket.py 
b/rpython/rlib/test/test_rsocket.py
--- a/rpython/rlib/test/test_rsocket.py
+++ b/rpython/rlib/test/test_rsocket.py
@@ -67,27 +67,21 @@
 domain = 'google.com'
 result = [0] * nthreads
 threads = [None] * nthreads
-print 'starting', 70
 def lookup_name(i):
 name, aliases, address_list = gethostbyname_ex(domain)
 if name == domain:
 result[i] += 1
-print 'done',i,75
 for i in range(nthreads):
 threads[i] = threading.Thread(target = lookup_name, args=[i])
 threads[i].start()
-print 'threads', 78
-print 'done', 79
 for i in range(nthreads):
 threads[i].join()
 assert sum(result) == nthreads
-print 'done', 82
 
 def test_thread_safe_gethostbyaddr():
 import threading
 nthreads = 10
 ip = '8.8.8.8'
-print 'starting', 87
 domain = gethostbyaddr(ip)[0]
 result = [0] * nthreads
 threads = [None] * nthreads
@@ -98,7 +92,6 @@
 for i in range(nthreads):
 threads[i] = threading.Thread(target = lookup_addr, args=[ip, i])
 threads[i].start()
-print 'threads', 98
 for i in range(nthreads):
 threads[i].join()
 assert sum(result) == nthreads
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: merge upstream

2014-05-01 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: 
Changeset: r71144:4cc9b702d120
Date: 2014-05-01 10:52 -0700
http://bitbucket.org/pypy/pypy/changeset/4cc9b702d120/

Log:merge upstream

diff --git a/pypy/module/_rawffi/test/test__rawffi.py 
b/pypy/module/_rawffi/test/test__rawffi.py
--- a/pypy/module/_rawffi/test/test__rawffi.py
+++ b/pypy/module/_rawffi/test/test__rawffi.py
@@ -1084,27 +1084,27 @@
 s = S(autofree=True)
 b = buffer(s)
 assert len(b) == 40
-b[4] = 'X'
-b[:3] = 'ABC'
-assert b[:6] == 'ABC\x00X\x00'
+b[4] = b'X'
+b[:3] = b'ABC'
+assert b[:6] == b'ABC\x00X\x00'
 
 A = _rawffi.Array('c')
 a = A(10, autofree=True)
-a[3] = 'x'
+a[3] = b'x'
 b = buffer(a)
 assert len(b) == 10
-assert b[3] == 'x'
-b[6] = 'y'
-assert a[6] == 'y'
-b[3:5] = 'zt'
-assert a[3] == 'z'
-assert a[4] == 't'
+assert b[3] == b'x'
+b[6] = b'y'
+assert a[6] == b'y'
+b[3:5] = b'zt'
+assert a[3] == b'z'
+assert a[4] == b't'
 
 b = memoryview(a)
 assert len(b) == 10
-assert b[3] == 'z'
-b[3] = 'x'
-assert b[3] == 'x'
+assert b[3] == b'z'
+b[3] = b'x'
+assert b[3] == b'x'
 
 def test_union(self):
 import _rawffi
diff --git a/pypy/module/cppyy/pythonify.py b/pypy/module/cppyy/pythonify.py
--- a/pypy/module/cppyy/pythonify.py
+++ b/pypy/module/cppyy/pythonify.py
@@ -1,6 +1,7 @@
 # NOT_RPYTHON
 # do not load cppyy here, see _init_pythonify()
-import types, sys
+import types
+import sys
 
 
 # For now, keep namespaces and classes separate as namespaces are extensible
@@ -11,7 +12,7 @@
 def __getattr__(self, name):
 try:
 return get_pycppitem(self, name)  # will cache on self
-except Exception, e:
+except Exception as e:
 raise AttributeError(%s object has no attribute '%s' (details: 
%s) %
  (self, name, str(e)))
 
@@ -302,7 +303,7 @@
 return self._getitem__unchecked(idx)
 
 def python_style_sliceable_getitem(self, slice_or_idx):
-if type(slice_or_idx) == types.SliceType:
+if type(slice_or_idx) == slice:
 nseq = self.__class__()
 nseq += [python_style_getitem(self, i) \
 for i in range(*slice_or_idx.indices(len(self)))]
diff --git a/pypy/objspace/std/test/test_strbufobject.py 
b/pypy/objspace/std/test/test_strbufobject.py
--- a/pypy/objspace/std/test/test_strbufobject.py
+++ b/pypy/objspace/std/test/test_strbufobject.py
@@ -45,9 +45,9 @@
 assert len(t) == 4
 
 def test_buffer(self):
-s = 'a'.__add__('b')
-assert buffer(s) == buffer('ab')
-assert memoryview(s) == 'ab'
+s = b'a'.__add__(b'b')
+assert buffer(s) == buffer(b'ab')
+assert memoryview(s) == b'ab'
 
 def test_add_strbuf(self):
 # make three strbuf objects
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: py3k compat

2014-05-01 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: 
Changeset: r71140:cf6744cc5576
Date: 2014-04-29 17:03 -0700
http://bitbucket.org/pypy/pypy/changeset/cf6744cc5576/

Log:py3k compat

diff --git a/pypy/module/cppyy/pythonify.py b/pypy/module/cppyy/pythonify.py
--- a/pypy/module/cppyy/pythonify.py
+++ b/pypy/module/cppyy/pythonify.py
@@ -1,6 +1,7 @@
 # NOT_RPYTHON
 # do not load cppyy here, see _init_pythonify()
-import types, sys
+import types
+import sys
 
 
 # For now, keep namespaces and classes separate as namespaces are extensible
@@ -11,7 +12,7 @@
 def __getattr__(self, name):
 try:
 return get_pycppitem(self, name)  # will cache on self
-except Exception, e:
+except Exception as e:
 raise AttributeError(%s object has no attribute '%s' (details: 
%s) %
  (self, name, str(e)))
 
@@ -309,7 +310,7 @@
 return self._getitem__unchecked(idx)
 
 def python_style_sliceable_getitem(self, slice_or_idx):
-if type(slice_or_idx) == types.SliceType:
+if type(slice_or_idx) == slice:
 nseq = self.__class__()
 nseq += [python_style_getitem(self, i) \
 for i in range(*slice_or_idx.indices(len(self)))]
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: backout c94a4ee2aa7d: %T calls get_module_type_name now

2014-05-01 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: 
Changeset: r71143:45957dfd5ee6
Date: 2014-05-01 10:50 -0700
http://bitbucket.org/pypy/pypy/changeset/45957dfd5ee6/

Log:backout c94a4ee2aa7d: %T calls get_module_type_name now

diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -1415,10 +1415,10 @@
 
 def _getarg_error(self, expected, w_obj):
 if self.is_none(w_obj):
-name = None
+e = oefmt(self.w_TypeError, must be %s, not None, expected)
 else:
-name = self.type(w_obj).get_module_type_name()
-raise oefmt(self.w_TypeError, must be %s, not %s, expected, name)
+e = oefmt(self.w_TypeError, must be %s, not %T, expected, w_obj)
+raise e
 
 @specialize.arg(1)
 def getarg_w(self, code, w_obj):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: use get_module_type_name for %T so we more closely match cpython, at least for

2014-05-01 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: 
Changeset: r71142:1f2e9de489e6
Date: 2014-05-01 10:50 -0700
http://bitbucket.org/pypy/pypy/changeset/1f2e9de489e6/

Log:use get_module_type_name for %T so we more closely match cpython, at
least for builtin types

diff --git a/pypy/interpreter/error.py b/pypy/interpreter/error.py
--- a/pypy/interpreter/error.py
+++ b/pypy/interpreter/error.py
@@ -362,9 +362,9 @@
 value = getattr(self, attr)
 if fmt == 'R':
 result = space.str_w(space.repr(value))
-elif fmt in 'NT':
-if fmt == 'T':
-value = space.type(value)
+elif fmt == 'T':
+result = space.type(value).get_module_type_name()
+elif fmt == 'N':
 result = value.getname(space)
 else:
 result = str(value)
@@ -404,7 +404,7 @@
 
 %N - The result of w_arg.getname(space)
 %R - The result of space.str_w(space.repr(w_arg))
-%T - The result of space.type(w_arg).getname(space)
+%T - The result of space.type(w_arg).get_module_type_name()
 
 
 if not len(args):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: py3k compat

2014-05-01 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: 
Changeset: r71141:5a6d4233a5f6
Date: 2014-04-29 17:10 -0700
http://bitbucket.org/pypy/pypy/changeset/5a6d4233a5f6/

Log:py3k compat

diff --git a/pypy/module/_rawffi/test/test__rawffi.py 
b/pypy/module/_rawffi/test/test__rawffi.py
--- a/pypy/module/_rawffi/test/test__rawffi.py
+++ b/pypy/module/_rawffi/test/test__rawffi.py
@@ -1084,27 +1084,27 @@
 s = S(autofree=True)
 b = buffer(s)
 assert len(b) == 40
-b[4] = 'X'
-b[:3] = 'ABC'
-assert b[:6] == 'ABC\x00X\x00'
+b[4] = b'X'
+b[:3] = b'ABC'
+assert b[:6] == b'ABC\x00X\x00'
 
 A = _rawffi.Array('c')
 a = A(10, autofree=True)
-a[3] = 'x'
+a[3] = b'x'
 b = buffer(a)
 assert len(b) == 10
-assert b[3] == 'x'
-b[6] = 'y'
-assert a[6] == 'y'
-b[3:5] = 'zt'
-assert a[3] == 'z'
-assert a[4] == 't'
+assert b[3] == b'x'
+b[6] = b'y'
+assert a[6] == b'y'
+b[3:5] = b'zt'
+assert a[3] == b'z'
+assert a[4] == b't'
 
 b = memoryview(a)
 assert len(b) == 10
-assert b[3] == 'z'
-b[3] = 'x'
-assert b[3] == 'x'
+assert b[3] == b'z'
+b[3] = b'x'
+assert b[3] == b'x'
 
 def test_union(self):
 import _rawffi
diff --git a/pypy/objspace/std/test/test_strbufobject.py 
b/pypy/objspace/std/test/test_strbufobject.py
--- a/pypy/objspace/std/test/test_strbufobject.py
+++ b/pypy/objspace/std/test/test_strbufobject.py
@@ -45,9 +45,9 @@
 assert len(t) == 4
 
 def test_buffer(self):
-s = 'a'.__add__('b')
-assert buffer(s) == buffer('ab')
-assert memoryview(s) == 'ab'
+s = b'a'.__add__(b'b')
+assert buffer(s) == buffer(b'ab')
+assert memoryview(s) == b'ab'
 
 def test_add_strbuf(self):
 # make three strbuf objects
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: merge heads

2014-05-01 Thread bdkearns
Author: Brian Kearns bdkea...@gmail.com
Branch: 
Changeset: r71146:45da6ce7a49e
Date: 2014-05-01 14:11 -0400
http://bitbucket.org/pypy/pypy/changeset/45da6ce7a49e/

Log:merge heads

diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -1415,10 +1415,10 @@
 
 def _getarg_error(self, expected, w_obj):
 if self.is_none(w_obj):
-name = None
+e = oefmt(self.w_TypeError, must be %s, not None, expected)
 else:
-name = self.type(w_obj).get_module_type_name()
-raise oefmt(self.w_TypeError, must be %s, not %s, expected, name)
+e = oefmt(self.w_TypeError, must be %s, not %T, expected, w_obj)
+raise e
 
 @specialize.arg(1)
 def getarg_w(self, code, w_obj):
diff --git a/pypy/interpreter/error.py b/pypy/interpreter/error.py
--- a/pypy/interpreter/error.py
+++ b/pypy/interpreter/error.py
@@ -362,9 +362,9 @@
 value = getattr(self, attr)
 if fmt == 'R':
 result = space.str_w(space.repr(value))
-elif fmt in 'NT':
-if fmt == 'T':
-value = space.type(value)
+elif fmt == 'T':
+result = space.type(value).get_module_type_name()
+elif fmt == 'N':
 result = value.getname(space)
 else:
 result = str(value)
@@ -404,7 +404,7 @@
 
 %N - The result of w_arg.getname(space)
 %R - The result of space.str_w(space.repr(w_arg))
-%T - The result of space.type(w_arg).getname(space)
+%T - The result of space.type(w_arg).get_module_type_name()
 
 
 if not len(args):
diff --git a/pypy/module/_rawffi/test/test__rawffi.py 
b/pypy/module/_rawffi/test/test__rawffi.py
--- a/pypy/module/_rawffi/test/test__rawffi.py
+++ b/pypy/module/_rawffi/test/test__rawffi.py
@@ -1084,27 +1084,27 @@
 s = S(autofree=True)
 b = buffer(s)
 assert len(b) == 40
-b[4] = 'X'
-b[:3] = 'ABC'
-assert b[:6] == 'ABC\x00X\x00'
+b[4] = b'X'
+b[:3] = b'ABC'
+assert b[:6] == b'ABC\x00X\x00'
 
 A = _rawffi.Array('c')
 a = A(10, autofree=True)
-a[3] = 'x'
+a[3] = b'x'
 b = buffer(a)
 assert len(b) == 10
-assert b[3] == 'x'
-b[6] = 'y'
-assert a[6] == 'y'
-b[3:5] = 'zt'
-assert a[3] == 'z'
-assert a[4] == 't'
+assert b[3] == b'x'
+b[6] = b'y'
+assert a[6] == b'y'
+b[3:5] = b'zt'
+assert a[3] == b'z'
+assert a[4] == b't'
 
 b = memoryview(a)
 assert len(b) == 10
-assert b[3] == 'z'
-b[3] = 'x'
-assert b[3] == 'x'
+assert b[3] == b'z'
+b[3] = b'x'
+assert b[3] == b'x'
 
 def test_union(self):
 import _rawffi
diff --git a/pypy/module/cppyy/pythonify.py b/pypy/module/cppyy/pythonify.py
--- a/pypy/module/cppyy/pythonify.py
+++ b/pypy/module/cppyy/pythonify.py
@@ -1,6 +1,7 @@
 # NOT_RPYTHON
 # do not load cppyy here, see _init_pythonify()
-import types, sys
+import types
+import sys
 
 
 # For now, keep namespaces and classes separate as namespaces are extensible
@@ -11,7 +12,7 @@
 def __getattr__(self, name):
 try:
 return get_pycppitem(self, name)  # will cache on self
-except Exception, e:
+except Exception as e:
 raise AttributeError(%s object has no attribute '%s' (details: 
%s) %
  (self, name, str(e)))
 
@@ -302,7 +303,7 @@
 return self._getitem__unchecked(idx)
 
 def python_style_sliceable_getitem(self, slice_or_idx):
-if type(slice_or_idx) == types.SliceType:
+if type(slice_or_idx) == slice:
 nseq = self.__class__()
 nseq += [python_style_getitem(self, i) \
 for i in range(*slice_or_idx.indices(len(self)))]
diff --git a/pypy/objspace/std/test/test_strbufobject.py 
b/pypy/objspace/std/test/test_strbufobject.py
--- a/pypy/objspace/std/test/test_strbufobject.py
+++ b/pypy/objspace/std/test/test_strbufobject.py
@@ -45,9 +45,9 @@
 assert len(t) == 4
 
 def test_buffer(self):
-s = 'a'.__add__('b')
-assert buffer(s) == buffer('ab')
-assert memoryview(s) == 'ab'
+s = b'a'.__add__(b'b')
+assert buffer(s) == buffer(b'ab')
+assert memoryview(s) == b'ab'
 
 def test_add_strbuf(self):
 # make three strbuf objects
diff --git a/rpython/translator/c/gcc/trackgcroot.py 
b/rpython/translator/c/gcc/trackgcroot.py
--- a/rpython/translator/c/gcc/trackgcroot.py
+++ b/rpython/translator/c/gcc/trackgcroot.py
@@ -522,8 +522,6 @@
 'movnt', 'mfence', 'lfence', 'sfence',
 # bit manipulations
 'bextr',
-# 

[pypy-commit] pypy default: backout c8e9da1478dc, broke translation

2014-05-01 Thread bdkearns
Author: Brian Kearns bdkea...@gmail.com
Branch: 
Changeset: r71145:7b0b1b52601d
Date: 2014-05-01 14:11 -0400
http://bitbucket.org/pypy/pypy/changeset/7b0b1b52601d/

Log:backout c8e9da1478dc, broke translation

diff --git a/rpython/jit/metainterp/optimizeopt/optimizer.py 
b/rpython/jit/metainterp/optimizeopt/optimizer.py
--- a/rpython/jit/metainterp/optimizeopt/optimizer.py
+++ b/rpython/jit/metainterp/optimizeopt/optimizer.py
@@ -347,21 +347,6 @@
 def forget_numberings(self, box):
 self.optimizer.forget_numberings(box)
 
-def _can_optimize_call_pure(self, op):
-arg_consts = []
-for i in range(op.numargs()):
-arg = op.getarg(i)
-const = self.get_constant_box(arg)
-if const is None:
-return None
-arg_consts.append(const)
-else:
-# all constant arguments: check if we already know the result
-try:
-return self.optimizer.call_pure_results[arg_consts]
-except KeyError:
-return None
-
 
 class Optimizer(Optimization):
 
diff --git a/rpython/jit/metainterp/optimizeopt/pure.py 
b/rpython/jit/metainterp/optimizeopt/pure.py
--- a/rpython/jit/metainterp/optimizeopt/pure.py
+++ b/rpython/jit/metainterp/optimizeopt/pure.py
@@ -57,16 +57,6 @@
 self.emit_operation(nextop)
 
 def optimize_CALL_PURE(self, op):
-# Step 1: check if all arguments are constant
-result = self._can_optimize_call_pure(op)
-if result is not None:
-# this removes a CALL_PURE with all constant arguments.
-self.make_constant(op.result, result)
-self.last_emitted_operation = REMOVED
-return
-
-# Step 2: check if all arguments are the same as a previous
-# CALL_PURE.
 args = self.optimizer.make_args_key(op)
 oldop = self.pure_operations.get(args, None)
 if oldop is not None and oldop.getdescr() is op.getdescr():
diff --git a/rpython/jit/metainterp/optimizeopt/rewrite.py 
b/rpython/jit/metainterp/optimizeopt/rewrite.py
--- a/rpython/jit/metainterp/optimizeopt/rewrite.py
+++ b/rpython/jit/metainterp/optimizeopt/rewrite.py
@@ -516,13 +516,24 @@
 return False
 
 def optimize_CALL_PURE(self, op):
-# this removes a CALL_PURE with all constant arguments.
-# Note that it's also done in pure.py.  For now we need both...
-result = self._can_optimize_call_pure(op)
-if result is not None:
-self.make_constant(op.result, result)
-self.last_emitted_operation = REMOVED
-return
+arg_consts = []
+for i in range(op.numargs()):
+arg = op.getarg(i)
+const = self.get_constant_box(arg)
+if const is None:
+break
+arg_consts.append(const)
+else:
+# all constant arguments: check if we already know the result
+try:
+result = self.optimizer.call_pure_results[arg_consts]
+except KeyError:
+pass
+else:
+# this removes a CALL_PURE with all constant arguments.
+self.make_constant(op.result, result)
+self.last_emitted_operation = REMOVED
+return
 self.emit_operation(op)
 
 def optimize_GUARD_NO_EXCEPTION(self, op):
diff --git a/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py 
b/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py
--- a/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py
+++ b/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py
@@ -5164,6 +5164,7 @@
 self.optimize_strunicode_loop(ops, expected)
 
 def test_call_pure_vstring_const(self):
+py.test.skip(implement me)
 ops = 
 []
 p0 = newstr(3)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: adjust per 1f2e9de489e6

2014-05-01 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: 
Changeset: r71147:ce13767ee917
Date: 2014-05-01 12:29 -0700
http://bitbucket.org/pypy/pypy/changeset/ce13767ee917/

Log:adjust per 1f2e9de489e6

diff --git a/pypy/module/_ast/test/test_ast.py 
b/pypy/module/_ast/test/test_ast.py
--- a/pypy/module/_ast/test/test_ast.py
+++ b/pypy/module/_ast/test/test_ast.py
@@ -218,19 +218,19 @@
 x = ast.Num()
 assert x._fields == ('n',)
 exc = raises(AttributeError, getattr, x, 'n')
-assert exc.value.args[0] == 'Num' object has no attribute 'n'
+assert Num' object has no attribute 'n' in exc.value.args[0]
 
 x = ast.Num(42)
 assert x.n == 42
 exc = raises(AttributeError, getattr, x, 'lineno')
-assert exc.value.args[0] == 'Num' object has no attribute 'lineno'
+assert Num' object has no attribute 'lineno' in exc.value.args[0]
 
 y = ast.Num()
 x.lineno = y
 assert x.lineno == y
 
 exc = raises(AttributeError, getattr, x, 'foobar')
-assert exc.value.args[0] == 'Num' object has no attribute 'foobar'
+assert Num' object has no attribute 'foobar' in exc.value.args[0]
 
 x = ast.Num(lineno=2)
 assert x.lineno == 2
@@ -423,4 +423,3 @@
 str_node2 = copy.deepcopy(str_node)
 dict_res = str_node2.__dict__
 assert dict_res == {'n':2, 'lineno':2}
-
\ No newline at end of file
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: skipped test showing difference

2014-05-01 Thread bdkearns
Author: Brian Kearns bdkea...@gmail.com
Branch: 
Changeset: r71148:c8d61f60c005
Date: 2014-05-01 15:38 -0400
http://bitbucket.org/pypy/pypy/changeset/c8d61f60c005/

Log:skipped test showing difference

diff --git a/pypy/module/_ast/test/test_ast.py 
b/pypy/module/_ast/test/test_ast.py
--- a/pypy/module/_ast/test/test_ast.py
+++ b/pypy/module/_ast/test/test_ast.py
@@ -19,6 +19,11 @@
 ast = self.ast
 assert isinstance(ast.__version__, str)
 
+def test_flags(self):
+skip(broken)
+from copy_reg import _HEAPTYPE
+assert self.ast.Module.__flags__  _HEAPTYPE
+
 def test_build_ast(self):
 ast = self.ast
 mod = self.get_ast(x = 4)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy issue1430: fix ztranslation

2014-05-01 Thread mattip
Author: mattip matti.pi...@gmail.com
Branch: issue1430
Changeset: r71151:78f3be62c4fb
Date: 2014-05-01 23:01 +0300
http://bitbucket.org/pypy/pypy/changeset/78f3be62c4fb/

Log:fix ztranslation

diff --git a/pypy/objspace/fake/checkmodule.py 
b/pypy/objspace/fake/checkmodule.py
--- a/pypy/objspace/fake/checkmodule.py
+++ b/pypy/objspace/fake/checkmodule.py
@@ -10,6 +10,7 @@
 mod = __import__('pypy.module.%s' % modname, None, None, ['__doc__'])
 # force computation and record what we wrap
 module = mod.Module(space, W_Root())
+module.startup(space)
 for name in module.loaders:
 seeobj_w.append(module._load_lazily(space, name))
 if hasattr(module, 'submodules'):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy issue1430: try a different approach

2014-05-01 Thread mattip
Author: mattip matti.pi...@gmail.com
Branch: issue1430
Changeset: r71149:87914f035951
Date: 2014-05-01 22:22 +0300
http://bitbucket.org/pypy/pypy/changeset/87914f035951/

Log:try a different approach

diff --git a/rpython/rlib/rsocket.py b/rpython/rlib/rsocket.py
--- a/rpython/rlib/rsocket.py
+++ b/rpython/rlib/rsocket.py
@@ -20,7 +20,6 @@
 from rpython.rlib.rarithmetic import intmask, r_uint
 from rpython.rtyper.lltypesystem import lltype, rffi
 from rpython.rtyper.lltypesystem.rffi import sizeof, offsetof
-from rpython.rlib import rthread
 INVALID_SOCKET = _c.INVALID_SOCKET
 
 def mallocbuf(buffersize):
@@ -30,8 +29,6 @@
 constants = _c.constants
 locals().update(constants) # Define constants from _c
 
-ll_locks = {}
-
 if _c.WIN32:
 from rpython.rlib import rwin32
 def rsocket_startup():
@@ -41,12 +38,9 @@
 assert res == 0
 finally:
 lltype.free(wsadata, flavor='raw')
-ll_locks['gethostbyname'] = rthread.allocate_lock()
-ll_locks['gethostbyaddr'] = rthread.allocate_lock()
 else:
 def rsocket_startup():
-ll_locks['gethostbyname'] = rthread.allocate_lock()
-ll_locks['gethostbyaddr'] = rthread.allocate_lock()
+pass
 
 
 def ntohs(x):
@@ -1130,18 +1124,18 @@
 paddr = h_addr_list[i]
 return (rffi.charp2str(hostent.c_h_name), aliases, address_list)
 
-def gethostbyname_ex(name):
+def gethostbyname_ex(name, lock):
 # XXX use gethostbyname_r() if available instead of locks
 addr = gethostbyname(name)
-with ll_locks['gethostbyname']:
+with lock:
 hostent = _c.gethostbyname(name)
 return gethost_common(name, hostent, addr)
 
-def gethostbyaddr(ip):
+def gethostbyaddr(ip, lock):
 # XXX use gethostbyaddr_r() if available, instead of locks
 addr = makeipaddr(ip)
 assert isinstance(addr, IPAddress)
-with ll_locks['gethostbyaddr']:
+with lock:
 p, size = addr.lock_in_addr()
 try:
 hostent = _c.gethostbyaddr(p, size, addr.family)
diff --git a/rpython/rlib/test/test_rsocket.py 
b/rpython/rlib/test/test_rsocket.py
--- a/rpython/rlib/test/test_rsocket.py
+++ b/rpython/rlib/test/test_rsocket.py
@@ -3,6 +3,14 @@
 from rpython.rlib.rsocket import *
 import socket as cpy_socket
 
+class DummyLock(object):
+def __enter__(self):
+pass
+
+def __exit__(self, *args):
+pass
+
+
 def setup_module(mod):
 rsocket_startup()
 
@@ -47,7 +55,7 @@
 
 def test_gethostbyname_ex():
 for host in [localhost, 127.0.0.1]:
-name, aliases, address_list = gethostbyname_ex(host)
+name, aliases, address_list = gethostbyname_ex(host, DummyLock())
 allnames = [name] + aliases
 for n in allnames:
 assert isinstance(n, str)
@@ -67,8 +75,9 @@
 domain = 'google.com'
 result = [0] * nthreads
 threads = [None] * nthreads
+lock = threading.Lock()
 def lookup_name(i):
-name, aliases, address_list = gethostbyname_ex(domain)
+name, aliases, address_list = gethostbyname_ex(domain, lock)
 if name == domain:
 result[i] += 1
 for i in range(nthreads):
@@ -82,11 +91,12 @@
 import threading
 nthreads = 10
 ip = '8.8.8.8'
-domain = gethostbyaddr(ip)[0]
+lock = threading.Lock()
+domain = gethostbyaddr(ip, lock)[0]
 result = [0] * nthreads
 threads = [None] * nthreads
 def lookup_addr(ip, i):
-name, aliases, address_list = gethostbyaddr(ip)
+name, aliases, address_list = gethostbyaddr(ip, lock)
 if name == domain:
 result[i] += 1
 for i in range(nthreads):
@@ -110,7 +120,7 @@
 with py.test.raises(ipv6):
 gethostbyaddr(host)
 continue
-name, aliases, address_list = gethostbyaddr(host)
+name, aliases, address_list = gethostbyaddr(host, DummyLock())
 allnames = [name] + aliases
 for n in allnames:
 assert isinstance(n, str)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy issue1430: add lock to pypy module, which will properly handle no-threading translation

2014-05-01 Thread mattip
Author: mattip matti.pi...@gmail.com
Branch: issue1430
Changeset: r71150:ea9e10befc8f
Date: 2014-05-01 23:01 +0300
http://bitbucket.org/pypy/pypy/changeset/ea9e10befc8f/

Log:add lock to pypy module, which will properly handle no-threading
translation

diff --git a/pypy/module/_socket/__init__.py b/pypy/module/_socket/__init__.py
--- a/pypy/module/_socket/__init__.py
+++ b/pypy/module/_socket/__init__.py
@@ -17,6 +17,7 @@
 def startup(self, space):
 from rpython.rlib.rsocket import rsocket_startup
 rsocket_startup()
+space.socket_gethostbyxxx_lock = space.allocate_lock()
 
 def buildloaders(cls):
 from rpython.rlib import rsocket
diff --git a/pypy/module/_socket/interp_func.py 
b/pypy/module/_socket/interp_func.py
--- a/pypy/module/_socket/interp_func.py
+++ b/pypy/module/_socket/interp_func.py
@@ -43,7 +43,7 @@
 for a host.  The host argument is a string giving a host name or IP number.
 
 try:
-res = rsocket.gethostbyname_ex(host)
+res = rsocket.gethostbyname_ex(host, space.socket_gethostbyxxx_lock)
 except SocketError, e:
 raise converted_error(space, e)
 return common_wrapgethost(space, res)
@@ -56,7 +56,7 @@
 for a host.  The host argument is a string giving a host name or IP number.
 
 try:
-res = rsocket.gethostbyaddr(host)
+res = rsocket.gethostbyaddr(host, space.socket_gethostbyxxx_lock)
 except SocketError, e:
 raise converted_error(space, e)
 return common_wrapgethost(space, res)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy issue1430: add State to module

2014-05-01 Thread mattip
Author: mattip matti.pi...@gmail.com
Branch: issue1430
Changeset: r71152:841653d07ec4
Date: 2014-05-02 00:01 +0300
http://bitbucket.org/pypy/pypy/changeset/841653d07ec4/

Log:add State to module

diff --git a/pypy/module/_socket/__init__.py b/pypy/module/_socket/__init__.py
--- a/pypy/module/_socket/__init__.py
+++ b/pypy/module/_socket/__init__.py
@@ -17,7 +17,8 @@
 def startup(self, space):
 from rpython.rlib.rsocket import rsocket_startup
 rsocket_startup()
-space.socket_gethostbyxxx_lock = space.allocate_lock()
+from pypy.module._socket.interp_func import State
+space.fromcache(State).alloc_lock(space)
 
 def buildloaders(cls):
 from rpython.rlib import rsocket
diff --git a/pypy/module/_socket/interp_func.py 
b/pypy/module/_socket/interp_func.py
--- a/pypy/module/_socket/interp_func.py
+++ b/pypy/module/_socket/interp_func.py
@@ -43,7 +43,8 @@
 for a host.  The host argument is a string giving a host name or IP number.
 
 try:
-res = rsocket.gethostbyname_ex(host, space.socket_gethostbyxxx_lock)
+lock = space.fromcache(State).gethostbyxxx_lock
+res = rsocket.gethostbyname_ex(host, lock)
 except SocketError, e:
 raise converted_error(space, e)
 return common_wrapgethost(space, res)
@@ -56,7 +57,8 @@
 for a host.  The host argument is a string giving a host name or IP number.
 
 try:
-res = rsocket.gethostbyaddr(host, space.socket_gethostbyxxx_lock)
+lock = space.fromcache(State).gethostbyxxx_lock
+res = rsocket.gethostbyaddr(host, lock)
 except SocketError, e:
 raise converted_error(space, e)
 return common_wrapgethost(space, res)
@@ -310,3 +312,11 @@
 raise OperationError(space.w_ValueError,
  space.wrap('Timeout value out of range'))
 rsocket.setdefaulttimeout(timeout)
+
+class State(object):
+def __init__(self, space):
+self.gethostbyxxx_lock = None
+
+def alloc_lock(self, space):
+self.gethostbyxxx_lock = space.allocate_lock()
+
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy issue1430: we don't expect socketerror from this

2014-05-01 Thread bdkearns
Author: Brian Kearns bdkea...@gmail.com
Branch: issue1430
Changeset: r71153:8e3ca2c46a2f
Date: 2014-05-01 17:05 -0400
http://bitbucket.org/pypy/pypy/changeset/8e3ca2c46a2f/

Log:we don't expect socketerror from this

diff --git a/pypy/module/_socket/interp_func.py 
b/pypy/module/_socket/interp_func.py
--- a/pypy/module/_socket/interp_func.py
+++ b/pypy/module/_socket/interp_func.py
@@ -42,8 +42,8 @@
 Return the true host name, a list of aliases, and a list of IP addresses,
 for a host.  The host argument is a string giving a host name or IP number.
 
+lock = space.fromcache(State).gethostbyxxx_lock
 try:
-lock = space.fromcache(State).gethostbyxxx_lock
 res = rsocket.gethostbyname_ex(host, lock)
 except SocketError, e:
 raise converted_error(space, e)
@@ -56,8 +56,8 @@
 Return the true host name, a list of aliases, and a list of IP addresses,
 for a host.  The host argument is a string giving a host name or IP number.
 
+lock = space.fromcache(State).gethostbyxxx_lock
 try:
-lock = space.fromcache(State).gethostbyxxx_lock
 res = rsocket.gethostbyaddr(host, lock)
 except SocketError, e:
 raise converted_error(space, e)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy issue1430: make API backward-compatible

2014-05-01 Thread mattip
Author: mattip matti.pi...@gmail.com
Branch: issue1430
Changeset: r71154:2e3fc0780b66
Date: 2014-05-02 00:14 +0300
http://bitbucket.org/pypy/pypy/changeset/2e3fc0780b66/

Log:make API backward-compatible

diff --git a/rpython/rlib/rsocket.py b/rpython/rlib/rsocket.py
--- a/rpython/rlib/rsocket.py
+++ b/rpython/rlib/rsocket.py
@@ -1124,14 +1124,22 @@
 paddr = h_addr_list[i]
 return (rffi.charp2str(hostent.c_h_name), aliases, address_list)
 
-def gethostbyname_ex(name, lock):
+class DummyLock(object):
+def __enter__(self):
+pass
+
+def __exit__(self, *args):
+pass
+
+
+def gethostbyname_ex(name, lock=DummyLock()):
 # XXX use gethostbyname_r() if available instead of locks
 addr = gethostbyname(name)
 with lock:
 hostent = _c.gethostbyname(name)
 return gethost_common(name, hostent, addr)
 
-def gethostbyaddr(ip, lock):
+def gethostbyaddr(ip, lock=DummyLock()):
 # XXX use gethostbyaddr_r() if available, instead of locks
 addr = makeipaddr(ip)
 assert isinstance(addr, IPAddress)
diff --git a/rpython/rlib/test/test_rsocket.py 
b/rpython/rlib/test/test_rsocket.py
--- a/rpython/rlib/test/test_rsocket.py
+++ b/rpython/rlib/test/test_rsocket.py
@@ -3,13 +3,6 @@
 from rpython.rlib.rsocket import *
 import socket as cpy_socket
 
-class DummyLock(object):
-def __enter__(self):
-pass
-
-def __exit__(self, *args):
-pass
-
 
 def setup_module(mod):
 rsocket_startup()
@@ -55,7 +48,7 @@
 
 def test_gethostbyname_ex():
 for host in [localhost, 127.0.0.1]:
-name, aliases, address_list = gethostbyname_ex(host, DummyLock())
+name, aliases, address_list = gethostbyname_ex(host)
 allnames = [name] + aliases
 for n in allnames:
 assert isinstance(n, str)
@@ -120,7 +113,7 @@
 with py.test.raises(ipv6):
 gethostbyaddr(host)
 continue
-name, aliases, address_list = gethostbyaddr(host, DummyLock())
+name, aliases, address_list = gethostbyaddr(host)
 allnames = [name] + aliases
 for n in allnames:
 assert isinstance(n, str)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: Try to constant-fold the CALL_PURE operation from *both* rewrite.py and

2014-05-01 Thread arigo
Author: Armin Rigo ar...@tunes.org
Branch: 
Changeset: r71155:e974d3f77576
Date: 2014-05-01 23:56 +0200
http://bitbucket.org/pypy/pypy/changeset/e974d3f77576/

Log:Try to constant-fold the CALL_PURE operation from *both* rewrite.py
and pure.py. (yet another attempt from c8e9da1478dc)

diff --git a/rpython/jit/metainterp/optimizeopt/optimizer.py 
b/rpython/jit/metainterp/optimizeopt/optimizer.py
--- a/rpython/jit/metainterp/optimizeopt/optimizer.py
+++ b/rpython/jit/metainterp/optimizeopt/optimizer.py
@@ -347,6 +347,21 @@
 def forget_numberings(self, box):
 self.optimizer.forget_numberings(box)
 
+def _can_optimize_call_pure(self, op):
+arg_consts = []
+for i in range(op.numargs()):
+arg = op.getarg(i)
+const = self.optimizer.get_constant_box(arg)
+if const is None:
+return None
+arg_consts.append(const)
+else:
+# all constant arguments: check if we already know the result
+try:
+return self.optimizer.call_pure_results[arg_consts]
+except KeyError:
+return None
+
 
 class Optimizer(Optimization):
 
diff --git a/rpython/jit/metainterp/optimizeopt/pure.py 
b/rpython/jit/metainterp/optimizeopt/pure.py
--- a/rpython/jit/metainterp/optimizeopt/pure.py
+++ b/rpython/jit/metainterp/optimizeopt/pure.py
@@ -57,6 +57,16 @@
 self.emit_operation(nextop)
 
 def optimize_CALL_PURE(self, op):
+# Step 1: check if all arguments are constant
+result = self._can_optimize_call_pure(op)
+if result is not None:
+# this removes a CALL_PURE with all constant arguments.
+self.make_constant(op.result, result)
+self.last_emitted_operation = REMOVED
+return
+
+# Step 2: check if all arguments are the same as a previous
+# CALL_PURE.
 args = self.optimizer.make_args_key(op)
 oldop = self.pure_operations.get(args, None)
 if oldop is not None and oldop.getdescr() is op.getdescr():
diff --git a/rpython/jit/metainterp/optimizeopt/rewrite.py 
b/rpython/jit/metainterp/optimizeopt/rewrite.py
--- a/rpython/jit/metainterp/optimizeopt/rewrite.py
+++ b/rpython/jit/metainterp/optimizeopt/rewrite.py
@@ -516,24 +516,13 @@
 return False
 
 def optimize_CALL_PURE(self, op):
-arg_consts = []
-for i in range(op.numargs()):
-arg = op.getarg(i)
-const = self.get_constant_box(arg)
-if const is None:
-break
-arg_consts.append(const)
-else:
-# all constant arguments: check if we already know the result
-try:
-result = self.optimizer.call_pure_results[arg_consts]
-except KeyError:
-pass
-else:
-# this removes a CALL_PURE with all constant arguments.
-self.make_constant(op.result, result)
-self.last_emitted_operation = REMOVED
-return
+# this removes a CALL_PURE with all constant arguments.
+# Note that it's also done in pure.py.  For now we need both...
+result = self._can_optimize_call_pure(op)
+if result is not None:
+self.make_constant(op.result, result)
+self.last_emitted_operation = REMOVED
+return
 self.emit_operation(op)
 
 def optimize_GUARD_NO_EXCEPTION(self, op):
diff --git a/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py 
b/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py
--- a/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py
+++ b/rpython/jit/metainterp/optimizeopt/test/test_optimizebasic.py
@@ -5164,7 +5164,6 @@
 self.optimize_strunicode_loop(ops, expected)
 
 def test_call_pure_vstring_const(self):
-py.test.skip(implement me)
 ops = 
 []
 p0 = newstr(3)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: put DummyLock in rthread

2014-05-01 Thread bdkearns
Author: Brian Kearns bdkea...@gmail.com
Branch: 
Changeset: r71156:c494afbfef83
Date: 2014-05-01 17:27 -0400
http://bitbucket.org/pypy/pypy/changeset/c494afbfef83/

Log:put DummyLock in rthread

diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -692,23 +692,17 @@
 def allocate_lock(self):
 Return an interp-level Lock object if threads are enabled,
 and a dummy object if they are not.
-if self.config.objspace.usemodules.thread:
-# we use a sub-function to avoid putting the 'import' statement
-# here, where the flow space would see it even if thread=False
-return self.__allocate_lock()
-else:
-return dummy_lock
-
-def __allocate_lock(self):
-from rpython.rlib.rthread import allocate_lock, error
+from rpython.rlib import rthread
+if not self.config.objspace.usemodules.thread:
+return rthread.dummy_lock
 # hack: we can't have prebuilt locks if we're translating.
 # In this special situation we should just not lock at all
 # (translation is not multithreaded anyway).
 if not we_are_translated() and self.config.translating:
 raise CannotHaveLock()
 try:
-return allocate_lock()
-except error:
+return rthread.allocate_lock()
+except rthread.error:
 raise OperationError(self.w_RuntimeError,
  self.wrap(out of resources))
 
@@ -1722,24 +1716,6 @@
 return space.getitem(w_glob, space.wrap('anonymous'))
 
 
-class DummyLock(object):
-def acquire(self, flag):
-return True
-
-def release(self):
-pass
-
-def _freeze_(self):
-return True
-
-def __enter__(self):
-pass
-
-def __exit__(self, *args):
-pass
-
-dummy_lock = DummyLock()
-
 # Table describing the regular part of the interface of object spaces,
 # namely all methods which only take w_ arguments and return a w_ result
 # (if any).
diff --git a/rpython/rlib/rthread.py b/rpython/rlib/rthread.py
--- a/rpython/rlib/rthread.py
+++ b/rpython/rlib/rthread.py
@@ -1,4 +1,3 @@
-
 from rpython.rtyper.lltypesystem import rffi, lltype, llmemory
 from rpython.translator.tool.cbuild import ExternalCompilationInfo
 from rpython.conftest import cdir
@@ -113,6 +112,24 @@
 assert len(y) == 0
 return rffi.cast(lltype.Signed, ll_start_new_thread(x))
 
+class DummyLock(object):
+def acquire(self, flag):
+return True
+
+def release(self):
+pass
+
+def _freeze_(self):
+return True
+
+def __enter__(self):
+pass
+
+def __exit__(self, *args):
+pass
+
+dummy_lock = DummyLock()
+
 class Lock(object):
  Container for low-level implementation
 of a lock object
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: merge heads

2014-05-01 Thread bdkearns
Author: Brian Kearns bdkea...@gmail.com
Branch: 
Changeset: r71157:0022e98eb8d3
Date: 2014-05-01 18:06 -0400
http://bitbucket.org/pypy/pypy/changeset/0022e98eb8d3/

Log:merge heads

diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -692,23 +692,17 @@
 def allocate_lock(self):
 Return an interp-level Lock object if threads are enabled,
 and a dummy object if they are not.
-if self.config.objspace.usemodules.thread:
-# we use a sub-function to avoid putting the 'import' statement
-# here, where the flow space would see it even if thread=False
-return self.__allocate_lock()
-else:
-return dummy_lock
-
-def __allocate_lock(self):
-from rpython.rlib.rthread import allocate_lock, error
+from rpython.rlib import rthread
+if not self.config.objspace.usemodules.thread:
+return rthread.dummy_lock
 # hack: we can't have prebuilt locks if we're translating.
 # In this special situation we should just not lock at all
 # (translation is not multithreaded anyway).
 if not we_are_translated() and self.config.translating:
 raise CannotHaveLock()
 try:
-return allocate_lock()
-except error:
+return rthread.allocate_lock()
+except rthread.error:
 raise OperationError(self.w_RuntimeError,
  self.wrap(out of resources))
 
@@ -1722,24 +1716,6 @@
 return space.getitem(w_glob, space.wrap('anonymous'))
 
 
-class DummyLock(object):
-def acquire(self, flag):
-return True
-
-def release(self):
-pass
-
-def _freeze_(self):
-return True
-
-def __enter__(self):
-pass
-
-def __exit__(self, *args):
-pass
-
-dummy_lock = DummyLock()
-
 # Table describing the regular part of the interface of object spaces,
 # namely all methods which only take w_ arguments and return a w_ result
 # (if any).
diff --git a/rpython/rlib/rthread.py b/rpython/rlib/rthread.py
--- a/rpython/rlib/rthread.py
+++ b/rpython/rlib/rthread.py
@@ -1,4 +1,3 @@
-
 from rpython.rtyper.lltypesystem import rffi, lltype, llmemory
 from rpython.translator.tool.cbuild import ExternalCompilationInfo
 from rpython.conftest import cdir
@@ -113,6 +112,24 @@
 assert len(y) == 0
 return rffi.cast(lltype.Signed, ll_start_new_thread(x))
 
+class DummyLock(object):
+def acquire(self, flag):
+return True
+
+def release(self):
+pass
+
+def _freeze_(self):
+return True
+
+def __enter__(self):
+pass
+
+def __exit__(self, *args):
+pass
+
+dummy_lock = DummyLock()
+
 class Lock(object):
  Container for low-level implementation
 of a lock object
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy issue1430: use dummy_lock from rthread

2014-05-01 Thread bdkearns
Author: Brian Kearns bdkea...@gmail.com
Branch: issue1430
Changeset: r71160:9ff62e96a9ed
Date: 2014-05-01 17:51 -0400
http://bitbucket.org/pypy/pypy/changeset/9ff62e96a9ed/

Log:use dummy_lock from rthread

diff --git a/rpython/rlib/rsocket.py b/rpython/rlib/rsocket.py
--- a/rpython/rlib/rsocket.py
+++ b/rpython/rlib/rsocket.py
@@ -18,6 +18,7 @@
 from rpython.rlib.objectmodel import instantiate, keepalive_until_here
 from rpython.rlib import _rsocket_rffi as _c
 from rpython.rlib.rarithmetic import intmask, r_uint
+from rpython.rlib.rthread import dummy_lock
 from rpython.rtyper.lltypesystem import lltype, rffi
 from rpython.rtyper.lltypesystem.rffi import sizeof, offsetof
 INVALID_SOCKET = _c.INVALID_SOCKET
@@ -1124,22 +1125,14 @@
 paddr = h_addr_list[i]
 return (rffi.charp2str(hostent.c_h_name), aliases, address_list)
 
-class DummyLock(object):
-def __enter__(self):
-pass
-
-def __exit__(self, *args):
-pass
-
-
-def gethostbyname_ex(name, lock=DummyLock()):
+def gethostbyname_ex(name, lock=dummy_lock):
 # XXX use gethostbyname_r() if available instead of locks
 addr = gethostbyname(name)
 with lock:
 hostent = _c.gethostbyname(name)
 return gethost_common(name, hostent, addr)
 
-def gethostbyaddr(ip, lock=DummyLock()):
+def gethostbyaddr(ip, lock=dummy_lock):
 # XXX use gethostbyaddr_r() if available, instead of locks
 addr = makeipaddr(ip)
 assert isinstance(addr, IPAddress)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy issue1430: cleanup

2014-05-01 Thread bdkearns
Author: Brian Kearns bdkea...@gmail.com
Branch: issue1430
Changeset: r71159:527d7902252d
Date: 2014-05-01 18:03 -0400
http://bitbucket.org/pypy/pypy/changeset/527d7902252d/

Log:cleanup

diff --git a/pypy/module/_socket/__init__.py b/pypy/module/_socket/__init__.py
--- a/pypy/module/_socket/__init__.py
+++ b/pypy/module/_socket/__init__.py
@@ -18,7 +18,7 @@
 from rpython.rlib.rsocket import rsocket_startup
 rsocket_startup()
 from pypy.module._socket.interp_func import State
-space.fromcache(State).alloc_lock(space)
+space.fromcache(State).startup(space)
 
 def buildloaders(cls):
 from rpython.rlib import rsocket
diff --git a/pypy/module/_socket/interp_func.py 
b/pypy/module/_socket/interp_func.py
--- a/pypy/module/_socket/interp_func.py
+++ b/pypy/module/_socket/interp_func.py
@@ -42,7 +42,7 @@
 Return the true host name, a list of aliases, and a list of IP addresses,
 for a host.  The host argument is a string giving a host name or IP number.
 
-lock = space.fromcache(State).gethostbyxxx_lock
+lock = space.fromcache(State).netdb_lock
 try:
 res = rsocket.gethostbyname_ex(host, lock)
 except SocketError, e:
@@ -56,7 +56,7 @@
 Return the true host name, a list of aliases, and a list of IP addresses,
 for a host.  The host argument is a string giving a host name or IP number.
 
-lock = space.fromcache(State).gethostbyxxx_lock
+lock = space.fromcache(State).netdb_lock
 try:
 res = rsocket.gethostbyaddr(host, lock)
 except SocketError, e:
@@ -315,8 +315,7 @@
 
 class State(object):
 def __init__(self, space):
-self.gethostbyxxx_lock = None
+self.netdb_lock = None
 
-def alloc_lock(self, space):
-self.gethostbyxxx_lock = space.allocate_lock()
-
+def startup(self, space):
+self.netdb_lock = space.allocate_lock()
diff --git a/rpython/rlib/test/test_rsocket.py 
b/rpython/rlib/test/test_rsocket.py
--- a/rpython/rlib/test/test_rsocket.py
+++ b/rpython/rlib/test/test_rsocket.py
@@ -84,10 +84,10 @@
 import threading
 nthreads = 10
 ip = '8.8.8.8'
-lock = threading.Lock()
-domain = gethostbyaddr(ip, lock)[0]
+domain = gethostbyaddr(ip)[0]
 result = [0] * nthreads
 threads = [None] * nthreads
+lock = threading.Lock()
 def lookup_addr(ip, i):
 name, aliases, address_list = gethostbyaddr(ip, lock)
 if name == domain:
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: cleanup

2014-05-01 Thread bdkearns
Author: Brian Kearns bdkea...@gmail.com
Branch: 
Changeset: r71161:1bb8ba9c96df
Date: 2014-05-01 19:46 -0400
http://bitbucket.org/pypy/pypy/changeset/1bb8ba9c96df/

Log:cleanup

diff --git a/pypy/module/_ast/test/test_ast.py 
b/pypy/module/_ast/test/test_ast.py
--- a/pypy/module/_ast/test/test_ast.py
+++ b/pypy/module/_ast/test/test_ast.py
@@ -249,9 +249,8 @@
 raises(TypeError, ast.Num, 1, 2, lineno=0)
 
 def test_issue1680_nonseq(self):
+# Test deleting an attribute manually
 
-# Test deleting an attribute manually
- 
 _ast = self.ast
 mod = self.get_ast(self.attr)
 assert isinstance(mod, _ast.Module)
@@ -292,9 +291,8 @@
 assert not hasattr(mod.body[0], 'name')
 
 def test_issue1680_seq(self):
+# Test deleting an attribute manually
 
-# Test deleting an attribute manually
- 
 _ast = self.ast
 mod = self.get_ast(self.attr)
 assert isinstance(mod, _ast.Module)
@@ -397,9 +395,8 @@
 import ast
 num_node = ast.Num(n=2, lineno=2, col_offset=3)
 dict_res = num_node.__dict__
-
 assert dict_res == {'n':2, 'lineno':2, 'col_offset':3}
-
+
 def test_issue1673_Num_notfullinit(self):
 import ast
 import copy
@@ -407,7 +404,7 @@
 assert num_node.n == 2
 assert num_node.lineno == 2
 num_node2 = copy.deepcopy(num_node)
-
+
 def test_issue1673_Num_fullinit(self):
 import ast
 import copy 
@@ -418,7 +415,7 @@
 assert num_node.col_offset == num_node2.col_offset
 dict_res = num_node2.__dict__
 assert dict_res == {'n':2, 'lineno':2, 'col_offset':3}
-  
+
 def test_issue1673_Str(self):
 import ast
 import copy
diff --git a/pypy/objspace/std/test/test_typeobject.py 
b/pypy/objspace/std/test/test_typeobject.py
--- a/pypy/objspace/std/test/test_typeobject.py
+++ b/pypy/objspace/std/test/test_typeobject.py
@@ -60,7 +60,6 @@
 
 
 class AppTestTypeObject:
-
 def test_abstract_methods(self):
 class X(object):
 pass
@@ -427,8 +426,7 @@
 assert f.__call__() == ((), {})
 assert f.__call__(hello, world) == ((hello, world), {})
 assert f.__call__(5, bla=6) == ((5,), {bla: 6})
-assert f.__call__(a=1, b=2, c=3) == ((), {a: 1, b: 2,
-   c: 3})
+assert f.__call__(a=1, b=2, c=3) == ((), {a: 1, b: 2, c: 3})
 
 def test_multipleinheritance_fail(self):
 try:
@@ -539,7 +537,6 @@
 assert ImmutableDoc.__doc__ == 'foo'
 
 def test_metaclass_conflict(self):
-
 class T1(type):
 pass
 class T2(type):
@@ -555,7 +552,7 @@
 
 def test_metaclass_choice(self):
 events = []
-
+
 class T1(type):
 def __new__(*args):
 events.append(args)
@@ -577,7 +574,7 @@
 assert type(D1) is T1
 assert type(C) is T1
 assert type(G) is T1
-
+
 def test_descr_typecheck(self):
 raises(TypeError,type.__dict__['__name__'].__get__,1)
 raises(TypeError,type.__dict__['__mro__'].__get__,1)
@@ -806,7 +803,7 @@
 z2 = Z2()
 z2.__class__ = Z1
 assert z2.__class__ == Z1
-
+
 class I(int):
 pass
 class F(float):
@@ -825,13 +822,12 @@
 pass
 
 i = I()
-
 i2 = I()
 i.__class__ = I2
 i2.__class__ = I
 assert i.__class__ ==  I2
 assert i2.__class__ == I
-
+
 i3 = I3()
 raises(TypeError, i3.__class__ = I2)
 i3.__class__ = I4
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: fix attribute error message for heap types

2014-05-01 Thread bdkearns
Author: Brian Kearns bdkea...@gmail.com
Branch: 
Changeset: r71162:02389a744344
Date: 2014-05-01 19:44 -0400
http://bitbucket.org/pypy/pypy/changeset/02389a744344/

Log:fix attribute error message for heap types

diff --git a/pypy/objspace/std/test/test_typeobject.py 
b/pypy/objspace/std/test/test_typeobject.py
--- a/pypy/objspace/std/test/test_typeobject.py
+++ b/pypy/objspace/std/test/test_typeobject.py
@@ -70,6 +70,13 @@
 raises(AttributeError, getattr, type, __abstractmethods__)
 raises(TypeError, int.__abstractmethods__ = ('abc', ))
 
+def test_attribute_error(self):
+class X(object):
+__module__ = 'test'
+x = X()
+exc = raises(AttributeError, x.a)
+assert str(exc.value) == 'X' object has no attribute 'a'
+
 def test_call_type(self):
 assert type(42) is int
 C = type('C', (object,), {'x': lambda: 42})
diff --git a/pypy/objspace/std/typeobject.py b/pypy/objspace/std/typeobject.py
--- a/pypy/objspace/std/typeobject.py
+++ b/pypy/objspace/std/typeobject.py
@@ -489,11 +489,12 @@
 
 def get_module_type_name(w_self):
 space = w_self.space
-w_mod = w_self.get_module()
-if space.isinstance_w(w_mod, space.w_str):
-mod = space.str_w(w_mod)
-if mod != '__builtin__':
-return '%s.%s' % (mod, w_self.name)
+if not w_self.is_heaptype():
+w_mod = w_self.get_module()
+if space.isinstance_w(w_mod, space.w_str):
+mod = space.str_w(w_mod)
+if mod != '__builtin__':
+return '%s.%s' % (mod, w_self.name)
 return w_self.name
 
 def getname(w_self, space):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: py3 compat

2014-05-01 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: 
Changeset: r71163:da193f0b119d
Date: 2014-05-01 16:55 -0700
http://bitbucket.org/pypy/pypy/changeset/da193f0b119d/

Log:py3 compat

diff --git a/pypy/module/_lsprof/test/test_cprofile.py 
b/pypy/module/_lsprof/test/test_cprofile.py
--- a/pypy/module/_lsprof/test/test_cprofile.py
+++ b/pypy/module/_lsprof/test/test_cprofile.py
@@ -43,7 +43,7 @@
 )
 by_id = set()
 for entry in stats:
-if entry.code == f1.func_code:
+if entry.code == f1.__code__:
 assert len(entry.calls) == 2
 for subentry in entry.calls:
 assert subentry.code in expected
@@ -144,8 +144,8 @@
 entries = {}
 for entry in stats:
 entries[entry.code] = entry
-efoo = entries[foo.func_code]
-ebar = entries[bar.func_code]
+efoo = entries[foo.__code__]
+ebar = entries[bar.__code__]
 assert 0.9  efoo.totaltime  2.9
 # --- cannot test .inlinetime, because it does not include
 # --- the time spent doing the call to time.time()
@@ -219,12 +219,12 @@
 lines.remove(line)
 break
 else:
-print 'NOT FOUND:', pattern.rstrip('\n')
-print '--- GOT ---'
-print got
-print
-print '--- EXPECTED ---'
-print expected
+print('NOT FOUND: %s' % pattern.rstrip('\n'))
+print('--- GOT ---')
+print(got)
+print()
+print('--- EXPECTED ---')
+print(expected)
 assert False
 assert not lines
 finally:
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy issue1430: close branch for merging

2014-05-01 Thread bdkearns
Author: Brian Kearns bdkea...@gmail.com
Branch: issue1430
Changeset: r71164:a0b02011d93b
Date: 2014-05-01 19:50 -0400
http://bitbucket.org/pypy/pypy/changeset/a0b02011d93b/

Log:close branch for merging

___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: merge branch issue1430

2014-05-01 Thread bdkearns
Author: Brian Kearns bdkea...@gmail.com
Branch: 
Changeset: r71165:9fe91ecfce83
Date: 2014-05-01 19:50 -0400
http://bitbucket.org/pypy/pypy/changeset/9fe91ecfce83/

Log:merge branch issue1430

diff --git a/pypy/module/_socket/__init__.py b/pypy/module/_socket/__init__.py
--- a/pypy/module/_socket/__init__.py
+++ b/pypy/module/_socket/__init__.py
@@ -17,6 +17,8 @@
 def startup(self, space):
 from rpython.rlib.rsocket import rsocket_startup
 rsocket_startup()
+from pypy.module._socket.interp_func import State
+space.fromcache(State).startup(space)
 
 def buildloaders(cls):
 from rpython.rlib import rsocket
diff --git a/pypy/module/_socket/interp_func.py 
b/pypy/module/_socket/interp_func.py
--- a/pypy/module/_socket/interp_func.py
+++ b/pypy/module/_socket/interp_func.py
@@ -42,8 +42,9 @@
 Return the true host name, a list of aliases, and a list of IP addresses,
 for a host.  The host argument is a string giving a host name or IP number.
 
+lock = space.fromcache(State).netdb_lock
 try:
-res = rsocket.gethostbyname_ex(host)
+res = rsocket.gethostbyname_ex(host, lock)
 except SocketError, e:
 raise converted_error(space, e)
 return common_wrapgethost(space, res)
@@ -55,8 +56,9 @@
 Return the true host name, a list of aliases, and a list of IP addresses,
 for a host.  The host argument is a string giving a host name or IP number.
 
+lock = space.fromcache(State).netdb_lock
 try:
-res = rsocket.gethostbyaddr(host)
+res = rsocket.gethostbyaddr(host, lock)
 except SocketError, e:
 raise converted_error(space, e)
 return common_wrapgethost(space, res)
@@ -310,3 +312,10 @@
 raise OperationError(space.w_ValueError,
  space.wrap('Timeout value out of range'))
 rsocket.setdefaulttimeout(timeout)
+
+class State(object):
+def __init__(self, space):
+self.netdb_lock = None
+
+def startup(self, space):
+self.netdb_lock = space.allocate_lock()
diff --git a/pypy/objspace/fake/checkmodule.py 
b/pypy/objspace/fake/checkmodule.py
--- a/pypy/objspace/fake/checkmodule.py
+++ b/pypy/objspace/fake/checkmodule.py
@@ -10,6 +10,7 @@
 mod = __import__('pypy.module.%s' % modname, None, None, ['__doc__'])
 # force computation and record what we wrap
 module = mod.Module(space, W_Root())
+module.startup(space)
 for name in module.loaders:
 seeobj_w.append(module._load_lazily(space, name))
 if hasattr(module, 'submodules'):
diff --git a/rpython/rlib/_rsocket_rffi.py b/rpython/rlib/_rsocket_rffi.py
--- a/rpython/rlib/_rsocket_rffi.py
+++ b/rpython/rlib/_rsocket_rffi.py
@@ -30,7 +30,7 @@
 'stdio.h',
 'netdb.h',
 'arpa/inet.h',
-'stdint.h', 
+'stdint.h',
 'errno.h',
 )
 if _HAS_AF_PACKET:
@@ -139,7 +139,7 @@
 EAI_SOCKTYPE EAI_SYSTEM
 
 IPPROTO_AH IPPROTO_BIP IPPROTO_DSTOPTS IPPROTO_EGP IPPROTO_EON IPPROTO_ESP
-IPPROTO_FRAGMENT IPPROTO_GGP IPPROTO_GRE IPPROTO_HELLO IPPROTO_HOPOPTS 
+IPPROTO_FRAGMENT IPPROTO_GGP IPPROTO_GRE IPPROTO_HELLO IPPROTO_HOPOPTS
 IPPROTO_ICMPV6 IPPROTO_IDP IPPROTO_IGMP IPPROTO_IPCOMP IPPROTO_IPIP
 IPPROTO_IPV4 IPPROTO_IPV6 IPPROTO_MAX IPPROTO_MOBILE IPPROTO_ND IPPROTO_NONE
 IPPROTO_PIM IPPROTO_PUP IPPROTO_ROUTING IPPROTO_RSVP IPPROTO_TCP IPPROTO_TP
@@ -174,7 +174,7 @@
 
 SOCK_DGRAM SOCK_RAW SOCK_RDM SOCK_SEQPACKET SOCK_STREAM
 
-SOL_SOCKET SOL_IPX SOL_AX25 SOL_ATALK SOL_NETROM SOL_ROSE 
+SOL_SOCKET SOL_IPX SOL_AX25 SOL_ATALK SOL_NETROM SOL_ROSE
 
 SO_ACCEPTCONN SO_BROADCAST SO_DEBUG SO_DONTROUTE SO_ERROR SO_EXCLUSIVEADDRUSE
 SO_KEEPALIVE SO_LINGER SO_OOBINLINE SO_RCVBUF SO_RCVLOWAT SO_RCVTIMEO
@@ -286,7 +286,7 @@
   ('nl_pid', rffi.INT),
   ('nl_groups', rffi.INT)],
  ifdef='AF_NETLINK')
- 
+
 CConfig.addrinfo = platform.Struct('struct addrinfo',
  [('ai_flags', rffi.INT),
   ('ai_family', rffi.INT),
diff --git a/rpython/rlib/rsocket.py b/rpython/rlib/rsocket.py
--- a/rpython/rlib/rsocket.py
+++ b/rpython/rlib/rsocket.py
@@ -18,6 +18,7 @@
 from rpython.rlib.objectmodel import instantiate, keepalive_until_here
 from rpython.rlib import _rsocket_rffi as _c
 from rpython.rlib.rarithmetic import intmask, r_uint
+from rpython.rlib.rthread import dummy_lock
 from rpython.rtyper.lltypesystem import lltype, rffi
 from rpython.rtyper.lltypesystem.rffi import sizeof, offsetof
 INVALID_SOCKET = _c.INVALID_SOCKET
@@ -1124,22 +1125,24 @@
 paddr = h_addr_list[i]
 return (rffi.charp2str(hostent.c_h_name), aliases, address_list)
 
-def gethostbyname_ex(name):
-# XXX use 

[pypy-commit] pypy default: merge heads

2014-05-01 Thread bdkearns
Author: Brian Kearns bdkea...@gmail.com
Branch: 
Changeset: r71167:2906656b373b
Date: 2014-05-01 19:59 -0400
http://bitbucket.org/pypy/pypy/changeset/2906656b373b/

Log:merge heads

diff --git a/pypy/module/_lsprof/test/test_cprofile.py 
b/pypy/module/_lsprof/test/test_cprofile.py
--- a/pypy/module/_lsprof/test/test_cprofile.py
+++ b/pypy/module/_lsprof/test/test_cprofile.py
@@ -43,7 +43,7 @@
 )
 by_id = set()
 for entry in stats:
-if entry.code == f1.func_code:
+if entry.code == f1.__code__:
 assert len(entry.calls) == 2
 for subentry in entry.calls:
 assert subentry.code in expected
@@ -144,8 +144,8 @@
 entries = {}
 for entry in stats:
 entries[entry.code] = entry
-efoo = entries[foo.func_code]
-ebar = entries[bar.func_code]
+efoo = entries[foo.__code__]
+ebar = entries[bar.__code__]
 assert 0.9  efoo.totaltime  2.9
 # --- cannot test .inlinetime, because it does not include
 # --- the time spent doing the call to time.time()
@@ -219,12 +219,12 @@
 lines.remove(line)
 break
 else:
-print 'NOT FOUND:', pattern.rstrip('\n')
-print '--- GOT ---'
-print got
-print
-print '--- EXPECTED ---'
-print expected
+print('NOT FOUND: %s' % pattern.rstrip('\n'))
+print('--- GOT ---')
+print(got)
+print()
+print('--- EXPECTED ---')
+print(expected)
 assert False
 assert not lines
 finally:
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: seqiter is good enough for default so kill our AraryIterator

2014-05-01 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r71169:2b304812a6bc
Date: 2014-05-01 17:34 -0700
http://bitbucket.org/pypy/pypy/changeset/2b304812a6bc/

Log:seqiter is good enough for default so kill our AraryIterator

diff --git a/pypy/module/array/interp_array.py 
b/pypy/module/array/interp_array.py
--- a/pypy/module/array/interp_array.py
+++ b/pypy/module/array/interp_array.py
@@ -517,9 +517,6 @@
 
 # Misc methods
 
-def descr_iter(self, space):
-return space.wrap(ArrayIterator(self))
-
 def descr_repr(self, space):
 if self.len == 0:
 return space.wrap(array('%s') % self.typecode)
@@ -557,7 +554,6 @@
 __radd__ = interp2app(W_ArrayBase.descr_radd),
 __rmul__ = interp2app(W_ArrayBase.descr_rmul),
 
-__iter__ = interp2app(W_ArrayBase.descr_iter),
 __repr__ = interp2app(W_ArrayBase.descr_repr),
 
 itemsize = GetSetProperty(descr_itemsize),
@@ -665,28 +661,6 @@
 return self.array._charbuf_start()
 
 
-class ArrayIterator(W_Root):
-def __init__(self, array):
-self.index = 0
-self.array = array
-
-def iter_w(self, space):
-return space.wrap(self)
-
-def next_w(self, space):
-if self.index  self.array.len:
-w_value = self.array.w_getitem(space, self.index)
-self.index += 1
-return w_value
-raise OperationError(space.w_StopIteration, space.w_None)
-
-ArrayIterator.typedef = TypeDef(
-'arrayiterator',
-__iter__ = interp2app(ArrayIterator.iter_w),
-__next__ = interp2app(ArrayIterator.next_w),
-)
-
-
 def make_array(mytype):
 W_ArrayBase = globals()['W_ArrayBase']
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: fix ztranslation

2014-05-01 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r71170:b9354e0d0dcd
Date: 2014-05-01 17:52 -0700
http://bitbucket.org/pypy/pypy/changeset/b9354e0d0dcd/

Log:fix ztranslation

diff --git a/pypy/objspace/fake/objspace.py b/pypy/objspace/fake/objspace.py
--- a/pypy/objspace/fake/objspace.py
+++ b/pypy/objspace/fake/objspace.py
@@ -65,7 +65,7 @@
 pass
 
 class W_MyType(W_MyObject):
-name = foobar
+name = ufoobar
 
 def __init__(self):
 self.mro_w = [w_some_obj(), w_some_obj()]
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy fix-tpname: adjust getname to work like cpython

2014-05-01 Thread bdkearns
Author: Brian Kearns bdkea...@gmail.com
Branch: fix-tpname
Changeset: r71172:5628f63f92cd
Date: 2014-05-01 20:58 -0400
http://bitbucket.org/pypy/pypy/changeset/5628f63f92cd/

Log:adjust getname to work like cpython

diff --git a/pypy/objspace/std/typeobject.py b/pypy/objspace/std/typeobject.py
--- a/pypy/objspace/std/typeobject.py
+++ b/pypy/objspace/std/typeobject.py
@@ -495,11 +495,15 @@
 return '%s.%s' % (mod, w_self.name)
 return w_self.name
 
-def getname(w_self, space):
-name = w_self.name
-if name is None:
-name = '?'
-return name
+def getname(self, space):
+if self.is_heaptype():
+return self.name
+else:
+dot = self.name.find('.')
+if dot != -1:
+return self.name[dot+1:]
+else:
+return self.name
 
 def add_subclass(w_self, w_subclass):
 space = w_self.space
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy fix-tpname: these pass again

2014-05-01 Thread bdkearns
Author: Brian Kearns bdkea...@gmail.com
Branch: fix-tpname
Changeset: r71174:74bf9b0ee01f
Date: 2014-05-01 21:18 -0400
http://bitbucket.org/pypy/pypy/changeset/74bf9b0ee01f/

Log:these pass again

diff --git a/pypy/module/_ast/test/test_ast.py 
b/pypy/module/_ast/test/test_ast.py
--- a/pypy/module/_ast/test/test_ast.py
+++ b/pypy/module/_ast/test/test_ast.py
@@ -223,19 +223,19 @@
 x = ast.Num()
 assert x._fields == ('n',)
 exc = raises(AttributeError, getattr, x, 'n')
-assert Num' object has no attribute 'n' in exc.value.args[0]
+assert str(exc.value) == 'Num' object has no attribute 'n'
 
 x = ast.Num(42)
 assert x.n == 42
 exc = raises(AttributeError, getattr, x, 'lineno')
-assert Num' object has no attribute 'lineno' in exc.value.args[0]
+assert str(exc.value) == 'Num' object has no attribute 'lineno'
 
 y = ast.Num()
 x.lineno = y
 assert x.lineno == y
 
 exc = raises(AttributeError, getattr, x, 'foobar')
-assert Num' object has no attribute 'foobar' in exc.value.args[0]
+assert str(exc.value) == 'Num' object has no attribute 'foobar'
 
 x = ast.Num(lineno=2)
 assert x.lineno == 2
@@ -407,7 +407,7 @@
 
 def test_issue1673_Num_fullinit(self):
 import ast
-import copy 
+import copy
 num_node = ast.Num(n=2,lineno=2,col_offset=3)
 num_node2 = copy.deepcopy(num_node)
 assert num_node.n == num_node2.n
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy fix-tpname: adjust get_module to work like cpython

2014-05-01 Thread bdkearns
Author: Brian Kearns bdkea...@gmail.com
Branch: fix-tpname
Changeset: r71171:78d387a3ea28
Date: 2014-05-01 20:39 -0400
http://bitbucket.org/pypy/pypy/changeset/78d387a3ea28/

Log:adjust get_module to work like cpython

diff --git a/pypy/objspace/std/typeobject.py b/pypy/objspace/std/typeobject.py
--- a/pypy/objspace/std/typeobject.py
+++ b/pypy/objspace/std/typeobject.py
@@ -473,19 +473,17 @@
 return res
 return _issubtype(w_self, w_type)
 
-def get_module(w_self):
-space = w_self.space
-if w_self.is_heaptype() and w_self.getdictvalue(space, '__module__') 
is not None:
-return w_self.getdictvalue(space, '__module__')
+def get_module(self):
+space = self.space
+if self.is_heaptype():
+return self.getdictvalue(space, '__module__')
 else:
-# for non-heap types, CPython checks for a module.name in the
-# type name.  That's a hack, so we're allowed to use a different
-# hack...
-if ('__module__' in w_self.dict_w and
-space.isinstance_w(w_self.getdictvalue(space, '__module__'),
-   space.w_str)):
-return w_self.getdictvalue(space, '__module__')
-return space.wrap('__builtin__')
+dot = self.name.find('.')
+if dot != -1:
+mod = self.name[:dot]
+else:
+mod = __builtin__
+return space.wrap(mod)
 
 def get_module_type_name(w_self):
 space = w_self.space
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy fix-tpname: kill get_module_type_name, fix some cases

2014-05-01 Thread bdkearns
Author: Brian Kearns bdkea...@gmail.com
Branch: fix-tpname
Changeset: r71173:2e04ced7667d
Date: 2014-05-01 21:13 -0400
http://bitbucket.org/pypy/pypy/changeset/2e04ced7667d/

Log:kill get_module_type_name, fix some cases

diff --git a/pypy/interpreter/error.py b/pypy/interpreter/error.py
--- a/pypy/interpreter/error.py
+++ b/pypy/interpreter/error.py
@@ -363,7 +363,7 @@
 if fmt == 'R':
 result = space.str_w(space.repr(value))
 elif fmt == 'T':
-result = space.type(value).get_module_type_name()
+result = space.type(value).name
 elif fmt == 'N':
 result = value.getname(space)
 else:
@@ -404,7 +404,7 @@
 
 %N - The result of w_arg.getname(space)
 %R - The result of space.str_w(space.repr(w_arg))
-%T - The result of space.type(w_arg).get_module_type_name()
+%T - The result of space.type(w_arg).name
 
 
 if not len(args):
diff --git a/pypy/module/_lsprof/interp_lsprof.py 
b/pypy/module/_lsprof/interp_lsprof.py
--- a/pypy/module/_lsprof/interp_lsprof.py
+++ b/pypy/module/_lsprof/interp_lsprof.py
@@ -199,7 +199,7 @@
 if isinstance(w_type, W_TypeObject):
 w_realclass, _ = space.lookup_in_type_where(w_type, name)
 if isinstance(w_realclass, W_TypeObject):
-class_name = w_realclass.get_module_type_name()
+class_name = w_realclass.name
 else:
 name = '?'
 if class_name is None:
@@ -440,7 +440,7 @@
 return space.wrap(p)
 
 W_Profiler.typedef = TypeDef(
-'Profiler',
+'_lsprof.Profiler',
 __module__ = '_lsprof',
 __new__ = interp2app(descr_new_profile),
 enable = interp2app(W_Profiler.enable),
diff --git a/pypy/module/array/interp_array.py 
b/pypy/module/array/interp_array.py
--- a/pypy/module/array/interp_array.py
+++ b/pypy/module/array/interp_array.py
@@ -488,7 +488,7 @@
 return space.wrap(s)
 
 W_ArrayBase.typedef = TypeDef(
-'array',
+'array.array',
 __new__ = interp2app(w_array),
 __module__ = 'array',
 
diff --git a/pypy/module/exceptions/interp_exceptions.py 
b/pypy/module/exceptions/interp_exceptions.py
--- a/pypy/module/exceptions/interp_exceptions.py
+++ b/pypy/module/exceptions/interp_exceptions.py
@@ -244,7 +244,7 @@
 for k, v in kwargs.items():
 kwargs[k] = interp2app(v.__get__(None, realbase))
 W_Exc.typedef = TypeDef(
-name,
+'exceptions.' + name,
 base.typedef,
 __doc__ = W_Exc.__doc__,
 __module__ = 'exceptions',
diff --git a/pypy/objspace/fake/objspace.py b/pypy/objspace/fake/objspace.py
--- a/pypy/objspace/fake/objspace.py
+++ b/pypy/objspace/fake/objspace.py
@@ -73,9 +73,6 @@
 def get_module(self):
 return w_some_obj()
 
-def get_module_type_name(self):
-return self.name
-
 def w_some_obj():
 if NonConstant(False):
 return W_Root()
diff --git a/pypy/objspace/std/typeobject.py b/pypy/objspace/std/typeobject.py
--- a/pypy/objspace/std/typeobject.py
+++ b/pypy/objspace/std/typeobject.py
@@ -485,16 +485,6 @@
 mod = __builtin__
 return space.wrap(mod)
 
-def get_module_type_name(w_self):
-space = w_self.space
-if not w_self.is_heaptype():
-w_mod = w_self.get_module()
-if space.isinstance_w(w_mod, space.w_str):
-mod = space.str_w(w_mod)
-if mod != '__builtin__':
-return '%s.%s' % (mod, w_self.name)
-return w_self.name
-
 def getname(self, space):
 if self.is_heaptype():
 return self.name
@@ -1113,7 +1103,7 @@
 else:
 kind = 'class'
 if mod is not None and mod != '__builtin__':
-return space.wrap(%s '%s.%s' % (kind, mod, w_obj.name))
+return space.wrap(%s '%s.%s' % (kind, mod, w_obj.getname(space)))
 else:
 return space.wrap(%s '%s' % (kind, w_obj.name))
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3k: fix translation

2014-05-01 Thread pjenvey
Author: Philip Jenvey pjen...@underboss.org
Branch: py3k
Changeset: r71175:f81c9ca6cbc2
Date: 2014-05-01 18:33 -0700
http://bitbucket.org/pypy/pypy/changeset/f81c9ca6cbc2/

Log:fix translation

diff --git a/pypy/module/_lsprof/interp_lsprof.py 
b/pypy/module/_lsprof/interp_lsprof.py
--- a/pypy/module/_lsprof/interp_lsprof.py
+++ b/pypy/module/_lsprof/interp_lsprof.py
@@ -215,7 +215,7 @@
 module = space.unicode_w(w_func.w_module)
 if module != u'builtins':
 return u'%s%s.%s' % (pre, module, w_func.getname(space))
-return '%s%s' % (pre, w_func.getname(space))
+return u'%s%s' % (pre, w_func.getname(space))
 
 
 def create_spec_for_object(space, w_type):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy fix-tpname: no longer necessary

2014-05-01 Thread bdkearns
Author: Brian Kearns bdkea...@gmail.com
Branch: fix-tpname
Changeset: r71180:e9280554e26d
Date: 2014-05-01 22:19 -0400
http://bitbucket.org/pypy/pypy/changeset/e9280554e26d/

Log:no longer necessary

diff --git a/pypy/module/array/interp_array.py 
b/pypy/module/array/interp_array.py
--- a/pypy/module/array/interp_array.py
+++ b/pypy/module/array/interp_array.py
@@ -490,7 +490,6 @@
 W_ArrayBase.typedef = TypeDef(
 'array.array',
 __new__ = interp2app(w_array),
-__module__ = 'array',
 
 __len__ = interp2app(W_ArrayBase.descr_len),
 __eq__ = interp2app(W_ArrayBase.descr_eq),
diff --git a/pypy/module/exceptions/interp_exceptions.py 
b/pypy/module/exceptions/interp_exceptions.py
--- a/pypy/module/exceptions/interp_exceptions.py
+++ b/pypy/module/exceptions/interp_exceptions.py
@@ -247,7 +247,6 @@
 'exceptions.' + name,
 base.typedef,
 __doc__ = W_Exc.__doc__,
-__module__ = 'exceptions',
 **kwargs
 )
 W_Exc.typedef.applevel_subclasses_base = realbase
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy fix-tpname: different approach for making _ast classes heaptypes

2014-05-01 Thread bdkearns
Author: Brian Kearns bdkea...@gmail.com
Branch: fix-tpname
Changeset: r71181:f84ebaac41fd
Date: 2014-05-01 23:48 -0400
http://bitbucket.org/pypy/pypy/changeset/f84ebaac41fd/

Log:different approach for making _ast classes heaptypes

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
@@ -2803,6 +2803,7 @@
 _attributes=_FieldsWrapper([]),
 __new__=interp2app(get_AST_new(mod)),
 )
+mod.typedef.heaptype = True
 
 def Module_get_body(space, w_self):
 if not w_self.initialization_state  1:
@@ -2850,6 +2851,7 @@
 __new__=interp2app(get_AST_new(Module)),
 __init__=interp2app(Module_init),
 )
+Module.typedef.heaptype = True
 
 def Interactive_get_body(space, w_self):
 if not w_self.initialization_state  1:
@@ -2897,6 +2899,7 @@
 __new__=interp2app(get_AST_new(Interactive)),
 __init__=interp2app(Interactive_init),
 )
+Interactive.typedef.heaptype = True
 
 def Expression_get_body(space, w_self):
 if w_self.w_dict is not None:
@@ -2950,6 +2953,7 @@
 __new__=interp2app(get_AST_new(Expression)),
 __init__=interp2app(Expression_init),
 )
+Expression.typedef.heaptype = True
 
 def Suite_get_body(space, w_self):
 if not w_self.initialization_state  1:
@@ -2997,6 +3001,7 @@
 __new__=interp2app(get_AST_new(Suite)),
 __init__=interp2app(Suite_init),
 )
+Suite.typedef.heaptype = True
 
 def stmt_get_lineno(space, w_self):
 if w_self.w_dict is not None:
@@ -3062,6 +3067,7 @@
 col_offset=typedef.GetSetProperty(stmt_get_col_offset, 
stmt_set_col_offset, stmt_del_col_offset, cls=stmt),
 __new__=interp2app(get_AST_new(stmt)),
 )
+stmt.typedef.heaptype = True
 
 def FunctionDef_get_name(space, w_self):
 if w_self.w_dict is not None:
@@ -3190,6 +3196,7 @@
 __new__=interp2app(get_AST_new(FunctionDef)),
 __init__=interp2app(FunctionDef_init),
 )
+FunctionDef.typedef.heaptype = True
 
 def ClassDef_get_name(space, w_self):
 if w_self.w_dict is not None:
@@ -3314,6 +3321,7 @@
 __new__=interp2app(get_AST_new(ClassDef)),
 __init__=interp2app(ClassDef_init),
 )
+ClassDef.typedef.heaptype = True
 
 def Return_get_value(space, w_self):
 if w_self.w_dict is not None:
@@ -3367,6 +3375,7 @@
 __new__=interp2app(get_AST_new(Return)),
 __init__=interp2app(Return_init),
 )
+Return.typedef.heaptype = True
 
 def Delete_get_targets(space, w_self):
 if not w_self.initialization_state  4:
@@ -3414,6 +3423,7 @@
 __new__=interp2app(get_AST_new(Delete)),
 __init__=interp2app(Delete_init),
 )
+Delete.typedef.heaptype = True
 
 def Assign_get_targets(space, w_self):
 if not w_self.initialization_state  4:
@@ -3491,6 +3501,7 @@
 __new__=interp2app(get_AST_new(Assign)),
 __init__=interp2app(Assign_init),
 )
+Assign.typedef.heaptype = True
 
 def AugAssign_get_target(space, w_self):
 if w_self.w_dict is not None:
@@ -3604,6 +3615,7 @@
 __new__=interp2app(get_AST_new(AugAssign)),
 __init__=interp2app(AugAssign_init),
 )
+AugAssign.typedef.heaptype = True
 
 def Print_get_dest(space, w_self):
 if w_self.w_dict is not None:
@@ -3710,6 +3722,7 @@
 __new__=interp2app(get_AST_new(Print)),
 __init__=interp2app(Print_init),
 )
+Print.typedef.heaptype = True
 
 def For_get_target(space, w_self):
 if w_self.w_dict is not None:
@@ -3841,6 +3854,7 @@
 __new__=interp2app(get_AST_new(For)),
 __init__=interp2app(For_init),
 )
+For.typedef.heaptype = True
 
 def While_get_test(space, w_self):
 if w_self.w_dict is not None:
@@ -3942,6 +3956,7 @@
 __new__=interp2app(get_AST_new(While)),
 __init__=interp2app(While_init),
 )
+While.typedef.heaptype = True
 
 def If_get_test(space, w_self):
 if w_self.w_dict is not None:
@@ -4043,6 +4058,7 @@
 __new__=interp2app(get_AST_new(If)),
 __init__=interp2app(If_init),
 )
+If.typedef.heaptype = True
 
 def With_get_context_expr(space, w_self):
 if w_self.w_dict is not None:
@@ -4150,6 +4166,7 @@
 __new__=interp2app(get_AST_new(With)),
 __init__=interp2app(With_init),
 )
+With.typedef.heaptype = True
 
 def Raise_get_type(space, w_self):
 if w_self.w_dict is not None:
@@ -4263,6 +4280,7 @@
 __new__=interp2app(get_AST_new(Raise)),
 __init__=interp2app(Raise_init),
 )
+Raise.typedef.heaptype = True
 
 def TryExcept_get_body(space, w_self):
 if not w_self.initialization_state  4:
@@ -4358,6 +4376,7 @@
 __new__=interp2app(get_AST_new(TryExcept)),
 __init__=interp2app(TryExcept_init),
 )
+TryExcept.typedef.heaptype = True
 
 def TryFinally_get_body(space, w_self):
 if not w_self.initialization_state  4:
@@ -4429,6 +4448,7 @@
 __new__=interp2app(get_AST_new(TryFinally)),
 __init__=interp2app(TryFinally_init),
 )
+TryFinally.typedef.heaptype = True
 
 def Assert_get_test(space, w_self):
 if w_self.w_dict is not None:
@@ -4512,6 +4532,7 @@
 __new__=interp2app(get_AST_new(Assert)),
 

[pypy-commit] pypy fix-tpname: merge default

2014-05-01 Thread bdkearns
Author: Brian Kearns bdkea...@gmail.com
Branch: fix-tpname
Changeset: r71178:df86bfb8787d
Date: 2014-05-01 21:37 -0400
http://bitbucket.org/pypy/pypy/changeset/df86bfb8787d/

Log:merge default

diff --git a/pypy/objspace/std/test/test_typeobject.py 
b/pypy/objspace/std/test/test_typeobject.py
--- a/pypy/objspace/std/test/test_typeobject.py
+++ b/pypy/objspace/std/test/test_typeobject.py
@@ -885,6 +885,12 @@
 Abc.__name__ = 'Def'
 assert Abc.__name__ == 'Def'
 raises(TypeError, Abc.__name__ = 42)
+try:
+Abc.__name__ = 'G\x00hi'
+except ValueError as e:
+assert str(e) == __name__ must not contain null bytes
+else:
+assert False
 
 def test_compare(self):
 class A(object):
diff --git a/pypy/objspace/std/typeobject.py b/pypy/objspace/std/typeobject.py
--- a/pypy/objspace/std/typeobject.py
+++ b/pypy/objspace/std/typeobject.py
@@ -626,7 +626,10 @@
 w_type = _check(space, w_type)
 if not w_type.is_heaptype():
 raise oefmt(space.w_TypeError, can't set %N.__name__, w_type)
-w_type.name = space.str_w(w_value)
+name = space.str_w(w_value)
+if '\x00' in name:
+raise oefmt(space.w_ValueError, __name__ must not contain null bytes)
+w_type.name = name
 
 def descr_get__mro__(space, w_type):
 w_type = _check(space, w_type)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy fix-tpname: fix _ast behavior

2014-05-01 Thread bdkearns
Author: Brian Kearns bdkea...@gmail.com
Branch: fix-tpname
Changeset: r71179:4d193ee033eb
Date: 2014-05-01 22:02 -0400
http://bitbucket.org/pypy/pypy/changeset/4d193ee033eb/

Log:fix _ast behavior

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
@@ -121,10 +121,9 @@
 for field, w_value in kwargs_w.iteritems():
 space.setattr(w_self, space.wrap(field), w_value)
 
-AST.typedef = typedef.TypeDef(AST,
+AST.typedef = typedef.TypeDef(_ast.AST,
 _fields=_FieldsWrapper([]),
 _attributes=_FieldsWrapper([]),
-__module__='_ast',
 __reduce__=interp2app(AST.reduce_w),
 __setstate__=interp2app(AST.setstate_w),
 __dict__ = typedef.GetSetProperty(typedef.descr_get_dict,
diff --git a/pypy/interpreter/astcompiler/tools/asdl_py.py 
b/pypy/interpreter/astcompiler/tools/asdl_py.py
--- a/pypy/interpreter/astcompiler/tools/asdl_py.py
+++ b/pypy/interpreter/astcompiler/tools/asdl_py.py
@@ -669,10 +669,9 @@
 for field, w_value in kwargs_w.iteritems():
 space.setattr(w_self, space.wrap(field), w_value)
 
-AST.typedef = typedef.TypeDef(AST,
+AST.typedef = typedef.TypeDef(_ast.AST,
 _fields=_FieldsWrapper([]),
 _attributes=_FieldsWrapper([]),
-__module__='_ast',
 __reduce__=interp2app(AST.reduce_w),
 __setstate__=interp2app(AST.setstate_w),
 __dict__ = typedef.GetSetProperty(typedef.descr_get_dict,
diff --git a/pypy/module/_ast/test/test_ast.py 
b/pypy/module/_ast/test/test_ast.py
--- a/pypy/module/_ast/test/test_ast.py
+++ b/pypy/module/_ast/test/test_ast.py
@@ -20,9 +20,9 @@
 assert isinstance(ast.__version__, str)
 
 def test_flags(self):
-skip(broken)
 from copy_reg import _HEAPTYPE
-assert self.ast.Module.__flags__  _HEAPTYPE
+assert self.ast.AST.__flags__  _HEAPTYPE == 0
+assert self.ast.Module.__flags__  _HEAPTYPE == _HEAPTYPE
 
 def test_build_ast(self):
 ast = self.ast
diff --git a/pypy/objspace/std/typeobject.py b/pypy/objspace/std/typeobject.py
--- a/pypy/objspace/std/typeobject.py
+++ b/pypy/objspace/std/typeobject.py
@@ -997,6 +997,7 @@
 w_self.weakrefable = w_self.instancetypedef.weakrefable
 w_self.w_doc = w_self.space.wrap(w_self.instancetypedef.doc)
 ensure_common_attributes(w_self)
+w_self.flag_heaptype = '__module__' in w_self.instancetypedef.rawdict
 
 def ensure_common_attributes(w_self):
 ensure_static_new(w_self)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit