[pypy-commit] pypy quad-color-gc: Update qcgc

2016-09-20 Thread ntruessel
Author: Nicolas Truessel 
Branch: quad-color-gc
Changeset: r87261:d78ddf89fd0b
Date: 2016-09-20 22:51 +0200
http://bitbucket.org/pypy/pypy/changeset/d78ddf89fd0b/

Log:Update qcgc

diff --git a/rpython/translator/c/src/qcgc/config.h 
b/rpython/translator/c/src/qcgc/config.h
--- a/rpython/translator/c/src/qcgc/config.h
+++ b/rpython/translator/c/src/qcgc/config.h
@@ -11,7 +11,8 @@
 #define EVENT_LOG 1// 
Enable event log
 #define LOGFILE "./qcgc_events.log"// Default logfile
 #define LOG_ALLOCATION 0   // Enable 
allocation log
-#define LOG_DUMP_FREELIST_STATS 1  // Dump freelist stats
+#define LOG_DUMP_FREELIST_STATS 0  // Dump freelist stats
+#define LOG_ALLOCATOR_SWITCH 0 // Log allocator 
switches
 
 #define QCGC_SHADOWSTACK_SIZE 163840   // Total shadowstack size
 #define QCGC_ARENA_BAG_INIT_SIZE 16// Initial size of the 
arena bag
@@ -19,7 +20,7 @@
 #define QCGC_LARGE_ALLOC_THRESHOLD_EXP 14  // Less than QCGC_ARENA_SIZE_EXP
 #define QCGC_MARK_LIST_SEGMENT_SIZE 64 // TODO: Tune for performance
 #define QCGC_GRAY_STACK_INIT_SIZE 128  // TODO: Tune for performance
-#define QCGC_INC_MARK_MIN 64   // TODO: Tune for 
performance
+#define QCGC_INC_MARK_MIN 1024 // TODO: Tune for 
performance
 
 /**
  * Fit allocator
@@ -31,8 +32,8 @@
 /**
  * Auto Mark/Collect
  */
-#define QCGC_INCMARK_THRESHOLD (1<<(QCGC_ARENA_SIZE_EXP-4))
-#define QCGC_INCMARK_TO_SWEEP 5
+#define QCGC_INCMARK_THRESHOLD (1<<(QCGC_ARENA_SIZE_EXP-5))
+#define QCGC_INCMARK_TO_SWEEP 10
 
 /**
  * DO NOT MODIFY BELOW HERE
diff --git a/rpython/translator/c/src/qcgc/qcgc.c 
b/rpython/translator/c/src/qcgc/qcgc.c
--- a/rpython/translator/c/src/qcgc/qcgc.c
+++ b/rpython/translator/c/src/qcgc/qcgc.c
@@ -88,6 +88,9 @@
 object_t *_qcgc_allocate_slowpath(size_t size) {
bool use_fit_allocator = _qcgc_bump_allocator.ptr == NULL;
size_t cells = bytes_to_cells(size);
+#if LOG_ALLOCATOR_SWITCH
+   bool old_use_fit_allocator = use_fit_allocator;
+#endif
 
if (UNLIKELY(qcgc_state.cells_since_incmark >
qcgc_state.incmark_threshold)) {
@@ -103,7 +106,7 @@
 
object_t *result = NULL;
if (!use_fit_allocator) {
-   qcgc_bump_allocator_renew_block(false);
+   qcgc_bump_allocator_renew_block(size, false);
 
qcgc_state.cells_since_incmark += _qcgc_bump_allocator.end -
_qcgc_bump_allocator.ptr;
@@ -124,16 +127,47 @@
 #endif
 
result->flags = QCGC_GRAY_FLAG;
+#if LOG_ALLOCATOR_SWITCH
+   if ((_qcgc_bump_allocator.ptr == NULL) != 
old_use_fit_allocator) {
+   // Allocator switched
+   struct log_info_s {
+   size_t allocations;
+   bool fit_allocator;
+   };
+   struct log_info_s log_info = {
+   qcgc_allocations,
+   _qcgc_bump_allocator.ptr == NULL,
+   };
+   qcgc_event_logger_log(EVENT_ALLOCATOR_SWITCH, 
sizeof(struct log_info_s),
+   (uint8_t *) _info);
+   }
+#endif
return result;
}
}
 
// Fit allocate
+   result = qcgc_fit_allocate(size);
if (result != NULL) {
qcgc_state.cells_since_incmark += bytes_to_cells(size);
+#if LOG_ALLOCATOR_SWITCH
+   if ((_qcgc_bump_allocator.ptr == NULL) != 
old_use_fit_allocator) {
+   // Allocator switched
+   struct log_info_s {
+   size_t allocations;
+   bool fit_allocator;
+   };
+   struct log_info_s log_info = {
+   qcgc_allocations,
+   _qcgc_bump_allocator.ptr == NULL,
+   };
+   qcgc_event_logger_log(EVENT_ALLOCATOR_SWITCH, 
sizeof(struct log_info_s),
+   (uint8_t *) _info);
+   }
+#endif
return result;
}
-   qcgc_bump_allocator_renew_block(true);
+   qcgc_bump_allocator_renew_block(size, true);
qcgc_state.cells_since_incmark +=
_qcgc_bump_allocator.end - _qcgc_bump_allocator.ptr;
 
@@ -150,6 +184,21 @@
 #endif
 
result->flags = QCGC_GRAY_FLAG;
+#if LOG_ALLOCATOR_SWITCH
+   if ((_qcgc_bump_allocator.ptr == NULL) != old_use_fit_allocator) {
+  

[pypy-commit] pypy value-classes: Remove dead code

2016-09-20 Thread sbauman
Author: Spenser Bauman 
Branch: value-classes
Changeset: r87258:d6ed7f0b5471
Date: 2016-09-20 13:06 -0400
http://bitbucket.org/pypy/pypy/changeset/d6ed7f0b5471/

Log:Remove dead code

diff --git a/rpython/rtyper/rclass.py b/rpython/rtyper/rclass.py
--- a/rpython/rtyper/rclass.py
+++ b/rpython/rtyper/rclass.py
@@ -576,7 +576,7 @@
 """Look for value class hints in the class heirarchy to extract the 
proper
 hints and ensure consistency of the _value_class_ annotation. This is
 mostly equivalent to _check_for_immutable_hints except that
-_value_class_=True imples _immutable_=True as well."""
+_value_class_=True imples _immutable_=True."""
 hints = hints.copy()
 classdesc = self.classdef.classdesc
 value_class = classdesc.get_param('_value_class_', inherit=False)
@@ -590,10 +590,6 @@
 raise TyperError(
 "class %r: _value_class_ = something else than True" % (
 self.classdef,))
-# elif not hints.get('immutable', False):
-# raise ValueClassConflictError(
-# "class %r: _value_class_ = True requires that "
-# "_immutable_ = True as well")
 else:
 # _value_class_ = True implies _immutable_ = True
 hints['value_class'] = True
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy value-classes: Add value_class information to SizeDescr

2016-09-20 Thread sbauman
Author: Spenser Bauman 
Branch: value-classes
Changeset: r87259:ad12c5eab511
Date: 2016-09-20 14:52 -0400
http://bitbucket.org/pypy/pypy/changeset/ad12c5eab511/

Log:Add value_class information to SizeDescr

diff --git a/rpython/jit/backend/llgraph/runner.py 
b/rpython/jit/backend/llgraph/runner.py
--- a/rpython/jit/backend/llgraph/runner.py
+++ b/rpython/jit/backend/llgraph/runner.py
@@ -139,6 +139,9 @@
 def is_immutable(self):
 return heaptracker.is_immutable_struct(self.S)
 
+def is_value_class(self):
+return heaptracker.is_value_class(self.S)
+
 def get_type_id(self):
 assert isinstance(self.S, lltype.GcStruct)
 return TypeIDSymbolic(self.S) # integer-like symbolic
diff --git a/rpython/jit/backend/llsupport/descr.py 
b/rpython/jit/backend/llsupport/descr.py
--- a/rpython/jit/backend/llsupport/descr.py
+++ b/rpython/jit/backend/llsupport/descr.py
@@ -61,16 +61,19 @@
 tid = llop.combine_ushort(lltype.Signed, 0, 0)
 vtable = lltype.nullptr(rclass.OBJECT_VTABLE)
 immutable_flag = False
+value_class_flag = False
 
 def __init__(self, size, gc_fielddescrs=None, all_fielddescrs=None,
  vtable=lltype.nullptr(rclass.OBJECT_VTABLE),
- immutable_flag=False):
+ immutable_flag=False,
+ value_class_flag=False):
 assert lltype.typeOf(vtable) == lltype.Ptr(rclass.OBJECT_VTABLE)
 self.size = size
 self.gc_fielddescrs = gc_fielddescrs
 self.all_fielddescrs = all_fielddescrs
 self.vtable = vtable
 self.immutable_flag = immutable_flag
+self.value_class_flag = value_class_flag
 
 def get_all_fielddescrs(self):
 return self.all_fielddescrs
@@ -94,6 +97,9 @@
 def is_immutable(self):
 return self.immutable_flag
 
+def is_value_class(self):
+return self.value_class_flag
+
 def get_vtable(self):
 return heaptracker.adr2int(llmemory.cast_ptr_to_adr(self.vtable))
 
@@ -109,12 +115,14 @@
 except KeyError:
 size = symbolic.get_size(STRUCT, gccache.translate_support_code)
 immutable_flag = heaptracker.is_immutable_struct(STRUCT)
+value_class_flag = heaptracker.is_value_class(STRUCT)
 if vtable:
 assert heaptracker.has_gcstruct_a_vtable(STRUCT)
 else:
 assert not heaptracker.has_gcstruct_a_vtable(STRUCT)
 sizedescr = SizeDescr(size, vtable=vtable,
-  immutable_flag=immutable_flag)
+  immutable_flag=immutable_flag,
+  value_class_flag=value_class_flag)
 gccache.init_size_descr(STRUCT, sizedescr)
 cache[STRUCT] = sizedescr
 # XXX do we really need gc_fielddescrs if we also have
diff --git a/rpython/jit/backend/llsupport/test/test_descr.py 
b/rpython/jit/backend/llsupport/test/test_descr.py
--- a/rpython/jit/backend/llsupport/test/test_descr.py
+++ b/rpython/jit/backend/llsupport/test/test_descr.py
@@ -52,6 +52,26 @@
 descr_s = get_size_descr(c0, STRUCT)
 assert descr_s.is_immutable() == True
 
+def test_get_size_descr_value_class():
+hints = {'immutable': True, 'value_class': True}
+S = lltype.GcStruct('S', hints=hints)
+T = lltype.GcStruct('T', ('parent', S),
+('x', lltype.Char),
+hints=hints)
+U = lltype.GcStruct('U', ('parent', T),
+('u', lltype.Ptr(T)),
+('v', lltype.Signed),
+hints=hints)
+V = lltype.GcStruct('V', ('parent', U),
+('miss1', lltype.Void),
+('miss2', lltype.Void),
+hints=hints)
+for STRUCT in [S, T, U, V]:
+for translated in [False, True]:
+c0 = GcCache(translated)
+descr_s = get_size_descr(c0, STRUCT)
+assert descr_s.is_value_class() == True
+
 def test_get_field_descr():
 U = lltype.Struct('U')
 T = lltype.GcStruct('T')
diff --git a/rpython/jit/codewriter/heaptracker.py 
b/rpython/jit/codewriter/heaptracker.py
--- a/rpython/jit/codewriter/heaptracker.py
+++ b/rpython/jit/codewriter/heaptracker.py
@@ -23,6 +23,9 @@
 def is_immutable_struct(S):
 return isinstance(S, lltype.GcStruct) and S._hints.get('immutable', False)
 
+def is_value_class(S):
+return isinstance(S, lltype.GcStruct) and S._hints.get('value_class', 
False)
+
 # 
 
 def has_gcstruct_a_vtable(GCSTRUCT):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy value-classes: GcStruct support for value_class hint

2016-09-20 Thread sbauman
Author: Spenser Bauman 
Branch: value-classes
Changeset: r87260:c37f0db2879f
Date: 2016-09-20 15:03 -0400
http://bitbucket.org/pypy/pypy/changeset/c37f0db2879f/

Log:GcStruct support for value_class hint

diff --git a/rpython/rtyper/lltypesystem/lltype.py 
b/rpython/rtyper/lltypesystem/lltype.py
--- a/rpython/rtyper/lltypesystem/lltype.py
+++ b/rpython/rtyper/lltypesystem/lltype.py
@@ -370,7 +370,8 @@
 return _struct(self, n, initialization='example')
 
 def _immutable_field(self, field):
-if self._hints.get('immutable'):
+if (self._hints.get('immutable') or
+self._hints.get('value_class')):
 return True
 if 'immutable_fields' in self._hints:
 try:
diff --git a/rpython/rtyper/lltypesystem/test/test_lltype.py 
b/rpython/rtyper/lltypesystem/test/test_lltype.py
--- a/rpython/rtyper/lltypesystem/test/test_lltype.py
+++ b/rpython/rtyper/lltypesystem/test/test_lltype.py
@@ -787,6 +787,11 @@
  hints={'immutable_fields': FieldListAccessor({'x': 1234})})
 assert S._immutable_field('x') == 1234
 
+def test_value_class_hint():
+S = GcStruct('S', ('x', lltype.Signed), hints={'value_class': True})
+assert S._immutable_field('x') == True
+assert S._hints.get('value_class', False) == True
+
 def test_typedef():
 T = Typedef(Signed, 'T')
 assert T == Signed
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy value-classes: _value_class_=True implies _immutable_=True for now

2016-09-20 Thread sbauman
Author: Spenser Bauman 
Branch: value-classes
Changeset: r87257:261d2a991cda
Date: 2016-09-20 13:01 -0400
http://bitbucket.org/pypy/pypy/changeset/261d2a991cda/

Log:_value_class_=True implies _immutable_=True for now May wish to do
away with _immutable_ in the future

diff --git a/rpython/rtyper/rclass.py b/rpython/rtyper/rclass.py
--- a/rpython/rtyper/rclass.py
+++ b/rpython/rtyper/rclass.py
@@ -545,6 +545,14 @@
 hints = hints.copy()
 classdesc = self.classdef.classdesc
 immut = classdesc.get_param('_immutable_', inherit=False)
+value_class = classdesc.get_param('_value_class_', inherit=False)
+
+if immut is None:
+immut = value_class
+elif value_class is not None and value_class and not immut:
+raise ImmutableConflictError(
+"class %r: _immutable_ != True and _value_class_ = True")
+
 if immut is None:
 if classdesc.get_param('_immutable_', inherit=True):
 raise ImmutableConflictError(
@@ -568,7 +576,7 @@
 """Look for value class hints in the class heirarchy to extract the 
proper
 hints and ensure consistency of the _value_class_ annotation. This is
 mostly equivalent to _check_for_immutable_hints except that
-_value_class_=True requires _immutable_=True as well."""
+_value_class_=True imples _immutable_=True as well."""
 hints = hints.copy()
 classdesc = self.classdef.classdesc
 value_class = classdesc.get_param('_value_class_', inherit=False)
@@ -582,12 +590,14 @@
 raise TyperError(
 "class %r: _value_class_ = something else than True" % (
 self.classdef,))
-elif not hints.get('immutable', False):
-raise ValueClassConflictError(
-"class %r: _value_class_ = True requires that "
-"_immutable_ = True as well")
+# elif not hints.get('immutable', False):
+# raise ValueClassConflictError(
+# "class %r: _value_class_ = True requires that "
+# "_immutable_ = True as well")
 else:
+# _value_class_ = True implies _immutable_ = True
 hints['value_class'] = True
+hints['immutable'] = True
 return hints
 
 def __repr__(self):
diff --git a/rpython/rtyper/test/test_rclass.py 
b/rpython/rtyper/test/test_rclass.py
--- a/rpython/rtyper/test/test_rclass.py
+++ b/rpython/rtyper/test/test_rclass.py
@@ -1309,7 +1309,6 @@
 def test_value_class(self):
 
 class I(object):
-_immutable_   = True
 _value_class_ = True
 
 def __init__(self, v):
@@ -1322,8 +1321,24 @@
 t, typer, graph = self.gengraph(f, [], backendopt=True)
 assert summary(graph) == {}
 
-def test_value_class_not_immutable(self):
-from rpython.rtyper.rclass import ValueClassConflictError
+def test_value_class_conflicts_with_immut(self):
+from rpython.rtyper.rclass import ImmutableConflictError
+
+class I(object):
+_immutable_   = False
+_value_class_ = True
+
+def __init__(self, v):
+self.v = v
+
+i = I(3)
+def f():
+return i.v
+
+py.test.raises(ImmutableConflictError, self.gengraph, f, [])
+
+def test_value_class_implies_immutable(self):
+from rpython.jit.metainterp.typesystem import deref
 
 class I(object):
 _value_class_ = True
@@ -1333,15 +1348,17 @@
 
 i = I(3)
 def f():
-return i.v
+return i
 
-py.test.raises(ValueClassConflictError, self.gengraph, f, [])
+t, typer, graph = self.gengraph(f, [])
+I_TYPE = deref(graph.getreturnvar().concretetype)
+assert I_TYPE._hints['immutable']
+assert I_TYPE._hints['value_class']
 
 def test_value_class_subclass_not_value_class(self):
 from rpython.rtyper.rclass import ValueClassConflictError
 
 class Base(object):
-_immutable_   = True
 _value_class_ = True
 
 class I(Base):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] extradoc extradoc: update

2016-09-20 Thread arigo
Author: Armin Rigo 
Branch: extradoc
Changeset: r5707:2e0b239248d6
Date: 2016-09-20 18:58 +0200
http://bitbucket.org/pypy/extradoc/changeset/2e0b239248d6/

Log:update

diff --git a/planning/py3.5/milestone-1-progress.rst 
b/planning/py3.5/milestone-1-progress.rst
--- a/planning/py3.5/milestone-1-progress.rst
+++ b/planning/py3.5/milestone-1-progress.rst
@@ -17,7 +17,7 @@
 * arigo: look at test failures relaced to os.scandir() or the pathlib
   module, or the enum module
 
-* arigo: review coroutines, add missing types like coroutine_wrapper
+* arigo: (py3k issue #2278) add full precision for st_mtime_ns
 
 
 
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy value-classes: Fix test

2016-09-20 Thread sbauman
Author: Spenser Bauman 
Branch: value-classes
Changeset: r87256:2c44eef6d8bd
Date: 2016-09-20 12:24 -0400
http://bitbucket.org/pypy/pypy/changeset/2c44eef6d8bd/

Log:Fix test

diff --git a/rpython/rtyper/rclass.py b/rpython/rtyper/rclass.py
--- a/rpython/rtyper/rclass.py
+++ b/rpython/rtyper/rclass.py
@@ -587,12 +587,6 @@
 "class %r: _value_class_ = True requires that "
 "_immutable_ = True as well")
 else:
-# Value classes may only be subclasses of other value classes
-basedesc = classdesc.basedesc
-if basedesc and not basedesc.get_param('_value_class_', False):
-raise ValueClassConflictError(
-"class %r: _value_class_ = True, but its parent "
-"class %r does not")
 hints['value_class'] = True
 return hints
 
diff --git a/rpython/rtyper/test/test_rclass.py 
b/rpython/rtyper/test/test_rclass.py
--- a/rpython/rtyper/test/test_rclass.py
+++ b/rpython/rtyper/test/test_rclass.py
@@ -1341,11 +1341,11 @@
 from rpython.rtyper.rclass import ValueClassConflictError
 
 class Base(object):
-_immutable_ = True
+_immutable_   = True
+_value_class_ = True
 
 class I(Base):
 _immutable_   = True
-_value_class_ = True
 
 def __init__(self, v):
 self.v = v
@@ -1355,3 +1355,4 @@
 return i.v
 
 py.test.raises(ValueClassConflictError, self.gengraph, f, [])
+
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy value-classes: Start working on _value_class_ annotation

2016-09-20 Thread sbauman
Author: Spenser Bauman 
Branch: value-classes
Changeset: r87255:7c0752bdace0
Date: 2016-09-20 12:07 -0400
http://bitbucket.org/pypy/pypy/changeset/7c0752bdace0/

Log:Start working on _value_class_ annotation

diff --git a/rpython/rtyper/rclass.py b/rpython/rtyper/rclass.py
--- a/rpython/rtyper/rclass.py
+++ b/rpython/rtyper/rclass.py
@@ -62,6 +62,9 @@
 """Raised when the _immutable_ or _immutable_fields_ hints are
 not consistent across a class hierarchy."""
 
+class ValueClassConflictError(Exception):
+"""Raise when the _value_class_ hints are not consistent across
+the class heirarchy"""
 
 def getclassrepr(rtyper, classdef):
 if classdef is None:
@@ -517,6 +520,7 @@
 if hints is None:
 hints = {}
 hints = self._check_for_immutable_hints(hints)
+hints = self._check_for_value_class_hints(hints)
 kwds = {}
 if self.gcflavor == 'gc':
 kwds['rtti'] = True
@@ -560,6 +564,38 @@
 hints['immutable_fields'] = accessor
 return hints
 
+def _check_for_value_class_hints(self, hints):
+"""Look for value class hints in the class heirarchy to extract the 
proper
+hints and ensure consistency of the _value_class_ annotation. This is
+mostly equivalent to _check_for_immutable_hints except that
+_value_class_=True requires _immutable_=True as well."""
+hints = hints.copy()
+classdesc = self.classdef.classdesc
+value_class = classdesc.get_param('_value_class_', inherit=False)
+if value_class is None:
+if classdesc.get_param('_value_class_', inherit=True):
+raise ValueClassConflictError(
+"class %r inherits from its parent _value_class_=True, "
+"so it should also declare _value_class_=True" % (
+self.classdef,))
+elif value_class is not True:
+raise TyperError(
+"class %r: _value_class_ = something else than True" % (
+self.classdef,))
+elif not hints.get('immutable', False):
+raise ValueClassConflictError(
+"class %r: _value_class_ = True requires that "
+"_immutable_ = True as well")
+else:
+# Value classes may only be subclasses of other value classes
+basedesc = classdesc.basedesc
+if basedesc and not basedesc.get_param('_value_class_', False):
+raise ValueClassConflictError(
+"class %r: _value_class_ = True, but its parent "
+"class %r does not")
+hints['value_class'] = True
+return hints
+
 def __repr__(self):
 if self.classdef is None:
 clsname = 'object'
diff --git a/rpython/rtyper/test/test_rclass.py 
b/rpython/rtyper/test/test_rclass.py
--- a/rpython/rtyper/test/test_rclass.py
+++ b/rpython/rtyper/test/test_rclass.py
@@ -1305,3 +1305,53 @@
 def f():
 return a.next.next.next.next is not None
 assert self.interpret(f, []) == True
+
+def test_value_class(self):
+
+class I(object):
+_immutable_   = True
+_value_class_ = True
+
+def __init__(self, v):
+self.v = v
+
+i = I(3)
+def f():
+return i.v
+
+t, typer, graph = self.gengraph(f, [], backendopt=True)
+assert summary(graph) == {}
+
+def test_value_class_not_immutable(self):
+from rpython.rtyper.rclass import ValueClassConflictError
+
+class I(object):
+_value_class_ = True
+
+def __init__(self, v):
+self.v = v
+
+i = I(3)
+def f():
+return i.v
+
+py.test.raises(ValueClassConflictError, self.gengraph, f, [])
+
+def test_value_class_subclass_not_value_class(self):
+from rpython.rtyper.rclass import ValueClassConflictError
+
+class Base(object):
+_immutable_ = True
+
+class I(Base):
+_immutable_   = True
+_value_class_ = True
+
+def __init__(self, v):
+self.v = v
+
+i = I(3)
+def f():
+return i.v
+
+py.test.raises(ValueClassConflictError, self.gengraph, f, [])
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy default: update to cffi/c61b49c67c83

2016-09-20 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r87254:e0a099a466a1
Date: 2016-09-20 15:23 +0200
http://bitbucket.org/pypy/pypy/changeset/e0a099a466a1/

Log:update to cffi/c61b49c67c83

diff --git a/lib_pypy/cffi.egg-info/PKG-INFO b/lib_pypy/cffi.egg-info/PKG-INFO
--- a/lib_pypy/cffi.egg-info/PKG-INFO
+++ b/lib_pypy/cffi.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: cffi
-Version: 1.8.3
+Version: 1.8.4
 Summary: Foreign Function Interface for Python calling C code.
 Home-page: http://cffi.readthedocs.org
 Author: Armin Rigo, Maciej Fijalkowski
diff --git a/lib_pypy/cffi/__init__.py b/lib_pypy/cffi/__init__.py
--- a/lib_pypy/cffi/__init__.py
+++ b/lib_pypy/cffi/__init__.py
@@ -4,8 +4,8 @@
 from .api import FFI, CDefError, FFIError
 from .ffiplatform import VerificationError, VerificationMissing
 
-__version__ = "1.8.3"
-__version_info__ = (1, 8, 3)
+__version__ = "1.8.4"
+__version_info__ = (1, 8, 4)
 
 # The verifier module file names are based on the CRC32 of a string that
 # contains the following version number.  It may be older than __version__
diff --git a/lib_pypy/cffi/_embedding.h b/lib_pypy/cffi/_embedding.h
--- a/lib_pypy/cffi/_embedding.h
+++ b/lib_pypy/cffi/_embedding.h
@@ -233,7 +233,7 @@
 f = PySys_GetObject((char *)"stderr");
 if (f != NULL && f != Py_None) {
 PyFile_WriteString("\nFrom: " _CFFI_MODULE_NAME
-   "\ncompiled with cffi version: 1.8.3"
+   "\ncompiled with cffi version: 1.8.4"
"\n_cffi_backend module: ", f);
 modules = PyImport_GetModuleDict();
 mod = PyDict_GetItemString(modules, "_cffi_backend");
diff --git a/lib_pypy/cffi/cparser.py b/lib_pypy/cffi/cparser.py
--- a/lib_pypy/cffi/cparser.py
+++ b/lib_pypy/cffi/cparser.py
@@ -332,7 +332,7 @@
 realtype = model.unknown_ptr_type(decl.name)
 else:
 realtype, quals = self._get_type_and_quals(
-decl.type, name=decl.name)
+decl.type, name=decl.name, partial_length_ok=True)
 self._declare('typedef ' + decl.name, realtype, 
quals=quals)
 else:
 raise api.CDefError("unrecognized construct", decl)
@@ -781,11 +781,14 @@
 exprnode.name in self._int_constants):
 return self._int_constants[exprnode.name]
 #
-if partial_length_ok:
-if (isinstance(exprnode, pycparser.c_ast.ID) and
+if (isinstance(exprnode, pycparser.c_ast.ID) and
 exprnode.name == '__dotdotdotarray__'):
+if partial_length_ok:
 self._partial_length = True
 return '...'
+raise api.FFIError(":%d: unsupported '[...]' here, cannot derive "
+   "the actual array length in this context"
+   % exprnode.coord.line)
 #
 raise api.FFIError(":%d: unsupported expression: expected a "
"simple numeric constant" % exprnode.coord.line)
diff --git a/lib_pypy/cffi/recompiler.py b/lib_pypy/cffi/recompiler.py
--- a/lib_pypy/cffi/recompiler.py
+++ b/lib_pypy/cffi/recompiler.py
@@ -587,8 +587,11 @@
 # --
 # typedefs
 
+def _typedef_type(self, tp, name):
+return self._global_type(tp, "(*(%s *)0)" % (name,))
+
 def _generate_cpy_typedef_collecttype(self, tp, name):
-self._do_collect_type(tp)
+self._do_collect_type(self._typedef_type(tp, name))
 
 def _generate_cpy_typedef_decl(self, tp, name):
 pass
@@ -598,6 +601,7 @@
 self._lsts["typename"].append(TypenameExpr(name, type_index))
 
 def _generate_cpy_typedef_ctx(self, tp, name):
+tp = self._typedef_type(tp, name)
 self._typedef_ctx(tp, name)
 if getattr(tp, "origin", None) == "unknown_type":
 self._struct_ctx(tp, tp.name, approxname=None)
diff --git a/pypy/module/_cffi_backend/__init__.py 
b/pypy/module/_cffi_backend/__init__.py
--- a/pypy/module/_cffi_backend/__init__.py
+++ b/pypy/module/_cffi_backend/__init__.py
@@ -3,7 +3,7 @@
 from rpython.rlib import rdynload, clibffi, entrypoint
 from rpython.rtyper.lltypesystem import rffi
 
-VERSION = "1.8.3"
+VERSION = "1.8.4"
 
 FFI_DEFAULT_ABI = clibffi.FFI_DEFAULT_ABI
 try:
diff --git a/pypy/module/_cffi_backend/test/_backend_test_c.py 
b/pypy/module/_cffi_backend/test/_backend_test_c.py
--- a/pypy/module/_cffi_backend/test/_backend_test_c.py
+++ b/pypy/module/_cffi_backend/test/_backend_test_c.py
@@ -1,7 +1,7 @@
 # 
 
 import sys
-assert __version__ == "1.8.3", ("This test_c.py file is for testing a version"
+assert __version__ == "1.8.4", ("This test_c.py file is for testing a version"
 " of cffi that differs from the one that 

[pypy-commit] cffi default: update to 1.8.4 and add whatsnew

2016-09-20 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r2776:c61b49c67c83
Date: 2016-09-20 15:12 +0200
http://bitbucket.org/cffi/cffi/changeset/c61b49c67c83/

Log:update to 1.8.4 and add whatsnew

diff --git a/c/_cffi_backend.c b/c/_cffi_backend.c
--- a/c/_cffi_backend.c
+++ b/c/_cffi_backend.c
@@ -2,7 +2,7 @@
 #include 
 #include "structmember.h"
 
-#define CFFI_VERSION  "1.8.3"
+#define CFFI_VERSION  "1.8.4"
 
 #ifdef MS_WIN32
 #include 
diff --git a/c/test_c.py b/c/test_c.py
--- a/c/test_c.py
+++ b/c/test_c.py
@@ -12,7 +12,7 @@
 # 
 
 import sys
-assert __version__ == "1.8.3", ("This test_c.py file is for testing a version"
+assert __version__ == "1.8.4", ("This test_c.py file is for testing a version"
 " of cffi that differs from the one that we"
 " get from 'import _cffi_backend'")
 if sys.version_info < (3,):
diff --git a/cffi/__init__.py b/cffi/__init__.py
--- a/cffi/__init__.py
+++ b/cffi/__init__.py
@@ -4,8 +4,8 @@
 from .api import FFI, CDefError, FFIError
 from .ffiplatform import VerificationError, VerificationMissing
 
-__version__ = "1.8.3"
-__version_info__ = (1, 8, 3)
+__version__ = "1.8.4"
+__version_info__ = (1, 8, 4)
 
 # The verifier module file names are based on the CRC32 of a string that
 # contains the following version number.  It may be older than __version__
diff --git a/cffi/_embedding.h b/cffi/_embedding.h
--- a/cffi/_embedding.h
+++ b/cffi/_embedding.h
@@ -233,7 +233,7 @@
 f = PySys_GetObject((char *)"stderr");
 if (f != NULL && f != Py_None) {
 PyFile_WriteString("\nFrom: " _CFFI_MODULE_NAME
-   "\ncompiled with cffi version: 1.8.3"
+   "\ncompiled with cffi version: 1.8.4"
"\n_cffi_backend module: ", f);
 modules = PyImport_GetModuleDict();
 mod = PyDict_GetItemString(modules, "_cffi_backend");
diff --git a/doc/source/conf.py b/doc/source/conf.py
--- a/doc/source/conf.py
+++ b/doc/source/conf.py
@@ -47,7 +47,7 @@
 # The short X.Y version.
 version = '1.8'
 # The full version, including alpha/beta/rc tags.
-release = '1.8.3'
+release = '1.8.4'
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.
diff --git a/doc/source/installation.rst b/doc/source/installation.rst
--- a/doc/source/installation.rst
+++ b/doc/source/installation.rst
@@ -51,13 +51,13 @@
 
 Download and Installation:
 
-* http://pypi.python.org/packages/source/c/cffi/cffi-1.8.3.tar.gz
+* http://pypi.python.org/packages/source/c/cffi/cffi-1.8.4.tar.gz
 
-   - MD5: c8e877fe0426a99d0cf5872cf2f95b27
+   - MD5: ...
 
-   - SHA: 2a5be10205bf3f6b21070a71ee2546d838868172
+   - SHA: ...
 
-   - SHA256: c321bd46faa7847261b89c0469569530cad5a41976bb6dba8202c0159f476568
+   - SHA256: ...
 
 * Or grab the most current version from the `Bitbucket page`_:
   ``hg clone https://bitbucket.org/cffi/cffi``
diff --git a/doc/source/whatsnew.rst b/doc/source/whatsnew.rst
--- a/doc/source/whatsnew.rst
+++ b/doc/source/whatsnew.rst
@@ -3,6 +3,14 @@
 ==
 
 
+v1.8.4
+==
+
+* Add support in ``cdef()/set_source()`` for unspecified-length arrays
+  in typedefs: ``typedef int foo_t[...];``.  It was already supported
+  for global variables or structure fields.
+
+
 v1.8.3
 ==
 
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -144,7 +144,7 @@
 
 `Mailing list `_
 """,
-version='1.8.3',
+version='1.8.4',
 packages=['cffi'] if cpython else [],
 package_data={'cffi': ['_cffi_include.h', 'parse_c_type.h', 
'_embedding.h']}
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] cffi default: typedef int foo_t[...];

2016-09-20 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r2775:8c38fb219286
Date: 2016-09-20 15:07 +0200
http://bitbucket.org/cffi/cffi/changeset/8c38fb219286/

Log:typedef int foo_t[...];

diff --git a/cffi/cparser.py b/cffi/cparser.py
--- a/cffi/cparser.py
+++ b/cffi/cparser.py
@@ -332,7 +332,7 @@
 realtype = model.unknown_ptr_type(decl.name)
 else:
 realtype, quals = self._get_type_and_quals(
-decl.type, name=decl.name)
+decl.type, name=decl.name, partial_length_ok=True)
 self._declare('typedef ' + decl.name, realtype, 
quals=quals)
 else:
 raise api.CDefError("unrecognized construct", decl)
@@ -781,11 +781,14 @@
 exprnode.name in self._int_constants):
 return self._int_constants[exprnode.name]
 #
-if partial_length_ok:
-if (isinstance(exprnode, pycparser.c_ast.ID) and
+if (isinstance(exprnode, pycparser.c_ast.ID) and
 exprnode.name == '__dotdotdotarray__'):
+if partial_length_ok:
 self._partial_length = True
 return '...'
+raise api.FFIError(":%d: unsupported '[...]' here, cannot derive "
+   "the actual array length in this context"
+   % exprnode.coord.line)
 #
 raise api.FFIError(":%d: unsupported expression: expected a "
"simple numeric constant" % exprnode.coord.line)
diff --git a/cffi/recompiler.py b/cffi/recompiler.py
--- a/cffi/recompiler.py
+++ b/cffi/recompiler.py
@@ -587,8 +587,11 @@
 # --
 # typedefs
 
+def _typedef_type(self, tp, name):
+return self._global_type(tp, "(*(%s *)0)" % (name,))
+
 def _generate_cpy_typedef_collecttype(self, tp, name):
-self._do_collect_type(tp)
+self._do_collect_type(self._typedef_type(tp, name))
 
 def _generate_cpy_typedef_decl(self, tp, name):
 pass
@@ -598,6 +601,7 @@
 self._lsts["typename"].append(TypenameExpr(name, type_index))
 
 def _generate_cpy_typedef_ctx(self, tp, name):
+tp = self._typedef_type(tp, name)
 self._typedef_ctx(tp, name)
 if getattr(tp, "origin", None) == "unknown_type":
 self._struct_ctx(tp, tp.name, approxname=None)
diff --git a/testing/cffi0/test_ffi_backend.py 
b/testing/cffi0/test_ffi_backend.py
--- a/testing/cffi0/test_ffi_backend.py
+++ b/testing/cffi0/test_ffi_backend.py
@@ -479,3 +479,7 @@
 assert ffi.unpack(p+1, 7) == b"bc\x00def\x00"
 p = ffi.new("int[]", [-123456789])
 assert ffi.unpack(p, 1) == [-123456789]
+
+def test_negative_array_size(self):
+ffi = FFI()
+py.test.raises(ValueError, ffi.cast, "int[-5]", 0)
diff --git a/testing/cffi1/test_ffi_obj.py b/testing/cffi1/test_ffi_obj.py
--- a/testing/cffi1/test_ffi_obj.py
+++ b/testing/cffi1/test_ffi_obj.py
@@ -502,3 +502,7 @@
 assert ffi.unpack(p+1, 7) == b"bc\x00def\x00"
 p = ffi.new("int[]", [-123456789])
 assert ffi.unpack(p, 1) == [-123456789]
+
+def test_negative_array_size():
+ffi = _cffi1_backend.FFI()
+py.test.raises(ffi.error, ffi.cast, "int[-5]", 0)
diff --git a/testing/cffi1/test_recompiler.py b/testing/cffi1/test_recompiler.py
--- a/testing/cffi1/test_recompiler.py
+++ b/testing/cffi1/test_recompiler.py
@@ -1980,3 +1980,29 @@
 static struct aaa f1(int x) { struct aaa s = {0}; s.a = x; return s; }
 """)
 assert lib.f1(52).a == 52
+
+def test_typedef_array_dotdotdot():
+ffi = FFI()
+ffi.cdef("""
+typedef int foo_t[...], bar_t[...];
+int gv[...];
+typedef int mat_t[...][...];
+typedef int vmat_t[][...];
+""")
+lib = verify(ffi, "test_typedef_array_dotdotdot", """
+typedef int foo_t[50], bar_t[50];
+int gv[23];
+typedef int mat_t[6][7];
+typedef int vmat_t[][8];
+""")
+assert ffi.sizeof("foo_t") == 50 * ffi.sizeof("int")
+assert ffi.sizeof("bar_t") == 50 * ffi.sizeof("int")
+assert len(ffi.new("foo_t")) == 50
+assert len(ffi.new("bar_t")) == 50
+assert ffi.sizeof(lib.gv) == 23 * ffi.sizeof("int")
+assert ffi.sizeof("mat_t") == 6 * 7 * ffi.sizeof("int")
+assert len(ffi.new("mat_t")) == 6
+assert len(ffi.new("mat_t")[3]) == 7
+py.test.raises(ffi.error, ffi.sizeof, "vmat_t")
+p = ffi.new("vmat_t", 4)
+assert ffi.sizeof(p[3]) == 8 * ffi.sizeof("int")
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy guard-compatible: fix fast isinstance check with guard_compatible

2016-09-20 Thread cfbolz
Author: Carl Friedrich Bolz 
Branch: guard-compatible
Changeset: r87253:ccf32f0e0a8d
Date: 2016-09-20 13:57 +0200
http://bitbucket.org/pypy/pypy/changeset/ccf32f0e0a8d/

Log:fix fast isinstance check with guard_compatible

diff --git a/pypy/module/__builtin__/abstractinst.py 
b/pypy/module/__builtin__/abstractinst.py
--- a/pypy/module/__builtin__/abstractinst.py
+++ b/pypy/module/__builtin__/abstractinst.py
@@ -102,7 +102,8 @@
 # PyObject_IsInstance() logic.
 
 # Quick test for an exact match
-if space.type(w_obj) is w_klass_or_tuple:
+# disabled with jit to make it not impose a strong type condition
+if not jit.we_are_jitted() and space.type(w_obj) is w_klass_or_tuple:
 return True
 
 # -- case (anything, tuple)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy guard-compatible: add debug prints to at least have a chance to figure out what is going on

2016-09-20 Thread cfbolz
Author: Carl Friedrich Bolz 
Branch: guard-compatible
Changeset: r87248:4f02e3d3f6f9
Date: 2016-08-23 15:03 +0100
http://bitbucket.org/pypy/pypy/changeset/4f02e3d3f6f9/

Log:add debug prints to at least have a chance to figure out what is
going on

diff --git a/rpython/jit/metainterp/compatible.py 
b/rpython/jit/metainterp/compatible.py
--- a/rpython/jit/metainterp/compatible.py
+++ b/rpython/jit/metainterp/compatible.py
@@ -2,6 +2,8 @@
 from rpython.jit.metainterp.history import newconst
 from rpython.jit.codewriter import longlong
 from rpython.jit.metainterp.resoperation import rop
+from rpython.rlib.debug import (have_debug_prints, debug_start, debug_stop,
+debug_print)
 
 def do_call(cpu, argboxes, descr):
 from rpython.jit.metainterp.history import INT, REF, FLOAT, VOID
@@ -64,8 +66,11 @@
 self.last_quasi_immut_field_op = op
 
 def check_compat(self, cpu, ref):
-for cond in self.conditions:
-if not cond.check(cpu, ref):
+for i, cond in enumerate(self.conditions):
+res = cond.check_and_return_result_if_different(cpu, ref)
+if res is not None:
+if have_debug_prints():
+debug_print("incompatible condition", i, ", got", 
cond._repr_const(res), ":", cond.repr())
 return False
 return True
 
@@ -168,7 +173,7 @@
 if const is None:
 return False
 ref = const.getref_base()
-if cond.check(cpu, ref):
+if cond.check_and_return_result_if_different(cpu, ref) is None:
 if not have_guard:
 # NB: the guard_compatible here needs to use const,
 # otherwise the optimizer will just complain
@@ -254,7 +259,9 @@
 self.debug_mp_str = s
 self.rpyfunc = None
 
-def check(self, cpu, ref):
+def check_and_return_result_if_different(self, cpu, ref):
+""" checks the condition using ref as an argument to the function. if
+the result is different, return the result. otherwise return None. """
 raise NotImplementedError
 
 def activate(self, ref, optimizer):
@@ -309,8 +316,7 @@
 self.descr = op.getdescr()
 self.rpyfunc = op.rpyfunc
 
-def check(self, cpu, ref):
-from rpython.rlib.debug import debug_print, debug_start, debug_stop
+def check_and_return_result_if_different(self, cpu, ref):
 calldescr = self.descr
 # change exactly the first argument
 arglist = self.args
@@ -318,15 +324,17 @@
 try:
 res = do_call(cpu, arglist, calldescr)
 except Exception:
-debug_start("jit-guard-compatible")
-debug_print("call to elidable_compatible function raised")
-debug_stop("jit-guard-compatible")
+if have_debug_prints():
+debug_start("jit-guard-compatible")
+debug_print("call to elidable_compatible function raised")
+debug_print(self.repr())
+debug_stop("jit-guard-compatible")
 return False
 finally:
 arglist[1] = None
 if not res.same_constant(self.res):
-return False
-return True
+return res
+return None
 
 def same_cond(self, other, res=None):
 if type(other) is not PureCallCondition:
@@ -433,7 +441,7 @@
  self.mutatefielddescr)
 qmut.register_loop_token(loop_token.loop_token_wref)
 
-def check(self, cpu, ref):
+def check_and_return_result_if_different(self, cpu, ref):
 from rpython.rlib.debug import debug_print, debug_start, debug_stop
 from rpython.jit.metainterp.quasiimmut import QuasiImmutDescr
 calldescr = self.descr
@@ -444,15 +452,17 @@
 try:
 res = do_call(cpu, arglist, calldescr)
 except Exception:
-debug_start("jit-guard-compatible")
-debug_print("call to elidable_compatible function raised")
-debug_stop("jit-guard-compatible")
+if have_debug_prints():
+debug_start("jit-guard-compatible")
+debug_print("call to elidable_compatible function raised")
+debug_print(self.repr())
+debug_stop("jit-guard-compatible")
 return False
 finally:
 arglist[1] = arglist[2] = None
 if not res.same_constant(self.res):
-return False
-return True
+return res
+return None
 
 def same_cond(self, other, res=None):
 if type(other) is not QuasiimmutGetfieldAndPureCallCondition:
diff --git a/rpython/jit/metainterp/compile.py 
b/rpython/jit/metainterp/compile.py
--- a/rpython/jit/metainterp/compile.py
+++ b/rpython/jit/metainterp/compile.py
@@ -1,7 +1,7 @@
 import weakref
 from rpython.rtyper.lltypesystem import 

[pypy-commit] pypy guard-compatible: somewhat obscure: if there is a condition on the "version" (ie second argument

2016-09-20 Thread cfbolz
Author: Carl Friedrich Bolz 
Branch: guard-compatible
Changeset: r87246:70a901ab0437
Date: 2016-08-18 15:41 +0200
http://bitbucket.org/pypy/pypy/changeset/70a901ab0437/

Log:somewhat obscure: if there is a condition on the "version" (ie
second argument of a elidable_compatible call) then that condition
was emmitted *after* the guard_compatible in the short preamble.
that's nonsense, fix it with a hack for now.

diff --git a/rpython/jit/metainterp/compatible.py 
b/rpython/jit/metainterp/compatible.py
--- a/rpython/jit/metainterp/compatible.py
+++ b/rpython/jit/metainterp/compatible.py
@@ -146,11 +146,13 @@
 """ re-emit the conditions about variable op into the short preamble
 """
 from rpython.jit.metainterp.resoperation import rop, ResOperation
-short.append(
+localshort = []
+localshort.append(
 ResOperation(rop.GUARD_COMPATIBLE, [
 op, self.known_valid]))
 for cond in self.conditions:
-cond.emit_condition(op, short, optimizer)
+cond.emit_condition(op, localshort, short, optimizer)
+short.extend(localshort)
 
 def emit_needed_conditions_if_const_matches(
 self, other, const, op, extra_guards, optimizer, cpu):
@@ -160,6 +162,7 @@
 at the end. """
 from rpython.jit.metainterp.resoperation import rop, ResOperation
 have_guard = False
+local_extra_guards = []
 for cond in self.conditions:
 if other is None or not other.contains_condition(cond):
 if const is None:
@@ -169,13 +172,16 @@
 if not have_guard:
 # NB: the guard_compatible here needs to use const,
 # otherwise the optimizer will just complain
-extra_guards.append(ResOperation(
+local_extra_guards.append(ResOperation(
 rop.GUARD_COMPATIBLE,
 [op, const]))
 have_guard = True
-cond.emit_condition(op, extra_guards, optimizer, const)
+cond.emit_condition(
+op, local_extra_guards,
+extra_guards, optimizer, const)
 else:
 return False
+extra_guards.extend(local_extra_guards)
 return True
 
 def attach_to_descr(self, descr, guard_value_op, optimizer):
@@ -263,7 +269,7 @@
 def repr(self):
 return ""
 
-def emit_condition(self, op, short, optimizer, const=None):
+def emit_condition(self, op, guards, pre_guards, optimizer, const=None):
 raise NotImplementedError("abstract base class")
 
 def _repr_const(self, arg):
@@ -341,7 +347,7 @@
 return False
 return True
 
-def emit_condition(self, op, short, optimizer, const=None):
+def emit_condition(self, op, short, pre_short, optimizer, const=None):
 from rpython.jit.metainterp.history import INT, REF, FLOAT, VOID
 from rpython.jit.metainterp.resoperation import rop, ResOperation
 # woah, mess
@@ -387,11 +393,14 @@
 res = self.debug_mp_str + "\n" + res
 return res
 
+class UnsupportedInfoInGuardCompatibleError(Exception):
+pass
 
 class QuasiimmutGetfieldAndPureCallCondition(PureCallCondition):
 const_args_start_at = 3
 
 def __init__(self, op, qmutdescr, optimizer):
+from rpython.jit.metainterp.optimizeopt import info
 PureCallCondition.__init__(self, op, optimizer)
 self.args[2] = None
 # XXX not 100% sure whether it's save to store the whole descr
@@ -399,6 +408,17 @@
 self.qmut = qmutdescr.qmut
 self.mutatefielddescr = qmutdescr.mutatefielddescr
 self.fielddescr = qmutdescr.fielddescr
+self.need_nonnull_arg2 = False
+if self.fielddescr.is_pointer_field():
+fieldinfo = optimizer.getptrinfo(op.getarg(2))
+if fieldinfo is not None:
+if type(fieldinfo) != info.NonNullPtrInfo:
+# XXX PyPy only needs non-null versions. if another
+# interpreter needs something more specific we need to
+# generalize this code
+raise UnsupportedInfoInGuardCompatible()
+else:
+self.need_nonnull_arg2 = True
 
 def activate(self, ref, optimizer):
 # record the quasi-immutable
@@ -458,7 +478,7 @@
 return False
 return True
 
-def emit_condition(self, op, short, optimizer, const=None):
+def emit_condition(self, op, short, pre_short, optimizer, const=None):
 from rpython.jit.metainterp.resoperation import rop, ResOperation
 from rpython.jit.metainterp.quasiimmut import QuasiImmutDescr
 # more mess
@@ -466,6 +486,13 @@
 if 

[pypy-commit] pypy guard-compatible: merge default

2016-09-20 Thread cfbolz
Author: Carl Friedrich Bolz 
Branch: guard-compatible
Changeset: r87252:d983a5a6f8ed
Date: 2016-09-20 13:53 +0200
http://bitbucket.org/pypy/pypy/changeset/d983a5a6f8ed/

Log:merge default

diff too long, truncating to 2000 out of 5948 lines

diff --git a/.hgtags b/.hgtags
--- a/.hgtags
+++ b/.hgtags
@@ -30,3 +30,6 @@
 68bb3510d8212ae9efb687e12e58c09d29e74f87 release-pypy2.7-v5.4.0
 68bb3510d8212ae9efb687e12e58c09d29e74f87 release-pypy2.7-v5.4.0
 77392ad263504df011ccfcabf6a62e21d04086d0 release-pypy2.7-v5.4.0
+050d84dd78997f021acf0e133934275d63547cc0 release-pypy2.7-v5.4.1
+050d84dd78997f021acf0e133934275d63547cc0 release-pypy2.7-v5.4.1
+0e2d9a73f5a1818d0245d75daccdbe21b2d5c3ef release-pypy2.7-v5.4.1
diff --git a/LICENSE b/LICENSE
--- a/LICENSE
+++ b/LICENSE
@@ -369,3 +369,109 @@
   Roman Podoliaka
   Dan Loewenherz
   werat
+
+  Heinrich-Heine University, Germany 
+  Open End AB (formerly AB Strakt), Sweden
+  merlinux GmbH, Germany 
+  tismerysoft GmbH, Germany 
+  Logilab Paris, France 
+  DFKI GmbH, Germany 
+  Impara, Germany
+  Change Maker, Sweden 
+  University of California Berkeley, USA
+  Google Inc.
+  King's College London
+
+The PyPy Logo as used by http://speed.pypy.org and others was created
+by Samuel Reis and is distributed on terms of Creative Commons Share Alike
+License.
+ 
+License for 'lib-python/2.7'
+
+
+Except when otherwise stated (look for LICENSE files or copyright/license
+information at the beginning of each file) the files in the 'lib-python/2.7'
+directory are all copyrighted by the Python Software Foundation and licensed
+under the terms that you can find here: https://docs.python.org/2/license.html
+
+License for 'pypy/module/unicodedata/'
+==
+
+The following files are from the website of The Unicode Consortium
+at http://www.unicode.org/.  For the terms of use of these files, see
+http://www.unicode.org/terms_of_use.html .  Or they are derived from
+files from the above website, and the same terms of use apply.
+
+CompositionExclusions-*.txt
+EastAsianWidth-*.txt
+LineBreak-*.txt
+UnicodeData-*.txt
+UnihanNumeric-*.txt
+
+License for 'dotviewer/font/'
+=
+
+Copyright (C) 2008 The Android Open Source Project
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+  
+ http://www.apache.org/licenses/LICENSE-2.0
+  
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+Detailed license information is contained in the NOTICE file in the
+directory.
+
+
+Licenses and Acknowledgements for Incorporated Software
+===
+
+This section is an incomplete, but growing list of licenses and
+acknowledgements for third-party software incorporated in the PyPy
+distribution.
+
+License for 'Tcl/Tk'
+
+
+This copy of PyPy contains library code that may, when used, result in
+the Tcl/Tk library to be loaded.  PyPy also includes code that may be
+regarded as being a copy of some parts of the Tcl/Tk header files.
+You may see a copy of the License for Tcl/Tk in the file
+`lib_pypy/_tkinter/license.terms` included here.
+
+License for 'bzip2'
+---
+
+This copy of PyPy may be linked (dynamically or statically) with the
+bzip2 library.  You may see a copy of the License for bzip2/libbzip2 at
+
+http://www.bzip.org/1.0.5/bzip2-manual-1.0.5.html
+
+License for 'openssl'
+-
+
+This copy of PyPy may be linked (dynamically or statically) with the
+openssl library.  You may see a copy of the License for OpenSSL at
+
+https://www.openssl.org/source/license.html
+
+License for 'gdbm'
+--
+
+The gdbm module includes code from gdbm.h, which is distributed under
+the terms of the GPL license version 2 or any later version.  Thus the
+gdbm module, provided in the file lib_pypy/gdbm.py, is redistributed
+under the terms of the GPL license as well.
+
+License for 'rpython/rlib/rvmprof/src'
+--
+
+The code is based on gperftools. You may see a copy of the License for it at
+
+https://github.com/gperftools/gperftools/blob/master/COPYING
diff --git a/_pytest/python.py b/_pytest/python.py
--- a/_pytest/python.py
+++ b/_pytest/python.py
@@ -498,7 +498,10 @@
 """ Collector for test methods. """
 def collect(self):
 if hasinit(self.obj):
-pytest.skip("class %s.%s with __init__ won't get collected" % (
+# XXX used to be skip(), but silently skipping classes
+# XXX just because they have been 

[pypy-commit] pypy guard-compatible: merge default

2016-09-20 Thread cfbolz
Author: Carl Friedrich Bolz 
Branch: guard-compatible
Changeset: r87251:fc880b5612ed
Date: 2016-09-01 10:06 +0200
http://bitbucket.org/pypy/pypy/changeset/fc880b5612ed/

Log:merge default

diff too long, truncating to 2000 out of 226692 lines

diff --git a/.hgtags b/.hgtags
--- a/.hgtags
+++ b/.hgtags
@@ -27,3 +27,6 @@
 40497617ae91caa1a394d8be6f9cd2de31cb0628 release-pypy3.3-v5.2
 c09c19272c990a0611b17569a0085ad1ab00c8ff release-pypy2.7-v5.3
 7e8df3df96417c16c2d55b41352ec82c9c69c978 release-pypy2.7-v5.3.1
+68bb3510d8212ae9efb687e12e58c09d29e74f87 release-pypy2.7-v5.4.0
+68bb3510d8212ae9efb687e12e58c09d29e74f87 release-pypy2.7-v5.4.0
+77392ad263504df011ccfcabf6a62e21d04086d0 release-pypy2.7-v5.4.0
diff --git a/LICENSE b/LICENSE
--- a/LICENSE
+++ b/LICENSE
@@ -74,6 +74,7 @@
   Seo Sanghyeon
   Ronny Pfannschmidt
   Justin Peel
+  Raffael Tfirst
   David Edelsohn
   Anders Hammarquist
   Jakub Gustak
@@ -117,7 +118,6 @@
   Wenzhu Man
   John Witulski
   Laurence Tratt
-  Raffael Tfirst
   Ivan Sichmann Freitas
   Greg Price
   Dario Bertini
@@ -141,6 +141,7 @@
   tav
   Taavi Burns
   Georg Brandl
+  Nicolas Truessel
   Bert Freudenberg
   Stian Andreassen
   Wanja Saatkamp
@@ -211,6 +212,7 @@
   Vaibhav Sood
   Alan McIntyre
   Alexander Sedov
+  p_ziesch...@yahoo.de
   Attila Gobi
   Jasper.Schulz
   Christopher Pope
@@ -221,6 +223,7 @@
   Arjun Naik
   Valentina Mukhamedzhanova
   Stefano Parmesan
+  touilleMan
   Alexis Daboville
   Jens-Uwe Mager
   Carl Meyer
@@ -229,12 +232,14 @@
   Gabriel
   Lukas Vacek
   Kunal Grover
+  Aaron Gallagher
   Andrew Dalke
   Sylvain Thenault
   Jakub Stasiak
   Nathan Taylor
   Vladimir Kryachko
   Omer Katz
+  Mark Williams
   Jacek Generowicz
   Alejandro J. Cura
   Jacob Oscarson
@@ -355,115 +360,12 @@
   yasirs
   Michael Chermside
   Anna Ravencroft
+  pizi
   Andrey Churin
   Dan Crosta
+  Eli Stevens
   Tobias Diaz
   Julien Phalip
   Roman Podoliaka
   Dan Loewenherz
-
-  Heinrich-Heine University, Germany 
-  Open End AB (formerly AB Strakt), Sweden
-  merlinux GmbH, Germany 
-  tismerysoft GmbH, Germany 
-  Logilab Paris, France 
-  DFKI GmbH, Germany 
-  Impara, Germany
-  Change Maker, Sweden 
-  University of California Berkeley, USA
-  Google Inc.
-  King's College London
-
-The PyPy Logo as used by http://speed.pypy.org and others was created
-by Samuel Reis and is distributed on terms of Creative Commons Share Alike
-License.
- 
-License for 'lib-python/2.7'
-
-
-Except when otherwise stated (look for LICENSE files or copyright/license
-information at the beginning of each file) the files in the 'lib-python/2.7'
-directory are all copyrighted by the Python Software Foundation and licensed
-under the terms that you can find here: https://docs.python.org/2/license.html
-
-License for 'pypy/module/unicodedata/'
-==
-
-The following files are from the website of The Unicode Consortium
-at http://www.unicode.org/.  For the terms of use of these files, see
-http://www.unicode.org/terms_of_use.html .  Or they are derived from
-files from the above website, and the same terms of use apply.
-
-CompositionExclusions-*.txt
-EastAsianWidth-*.txt
-LineBreak-*.txt
-UnicodeData-*.txt
-UnihanNumeric-*.txt
-
-License for 'dotviewer/font/'
-=
-
-Copyright (C) 2008 The Android Open Source Project
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-  
- http://www.apache.org/licenses/LICENSE-2.0
-  
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
-Detailed license information is contained in the NOTICE file in the
-directory.
-
-
-Licenses and Acknowledgements for Incorporated Software
-===
-
-This section is an incomplete, but growing list of licenses and
-acknowledgements for third-party software incorporated in the PyPy
-distribution.
-
-License for 'Tcl/Tk'
-
-
-This copy of PyPy contains library code that may, when used, result in
-the Tcl/Tk library to be loaded.  PyPy also includes code that may be
-regarded as being a copy of some parts of the Tcl/Tk header files.
-You may see a copy of the License for Tcl/Tk in the file
-`lib_pypy/_tkinter/license.terms` included here.
-
-License for 'bzip2'

-
-This copy of PyPy may be linked (dynamically or statically) with the
-bzip2 library.  You may see a copy of the License for bzip2/libbzip2 at
-
-http://www.bzip.org/1.0.5/bzip2-manual-1.0.5.html
-
-License for 'openssl'
--
-
-This copy of PyPy 

[pypy-commit] pypy guard-compatible: fix translation

2016-09-20 Thread cfbolz
Author: Carl Friedrich Bolz 
Branch: guard-compatible
Changeset: r87247:a53c8229dad7
Date: 2016-08-19 13:42 +0200
http://bitbucket.org/pypy/pypy/changeset/a53c8229dad7/

Log:fix translation

diff --git a/rpython/jit/metainterp/compatible.py 
b/rpython/jit/metainterp/compatible.py
--- a/rpython/jit/metainterp/compatible.py
+++ b/rpython/jit/metainterp/compatible.py
@@ -393,7 +393,7 @@
 res = self.debug_mp_str + "\n" + res
 return res
 
-class UnsupportedInfoInGuardCompatibleError(Exception):
+class UnsupportedInfoInGuardCompatible(Exception):
 pass
 
 class QuasiimmutGetfieldAndPureCallCondition(PureCallCondition):
@@ -412,7 +412,7 @@
 if self.fielddescr.is_pointer_field():
 fieldinfo = optimizer.getptrinfo(op.getarg(2))
 if fieldinfo is not None:
-if type(fieldinfo) != info.NonNullPtrInfo:
+if type(fieldinfo) is not info.NonNullPtrInfo:
 # XXX PyPy only needs non-null versions. if another
 # interpreter needs something more specific we need to
 # generalize this code
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy guard-compatible: just print the pointer constant

2016-09-20 Thread cfbolz
Author: Carl Friedrich Bolz 
Branch: guard-compatible
Changeset: r87250:f9845ecd2b54
Date: 2016-08-26 15:03 +0100
http://bitbucket.org/pypy/pypy/changeset/f9845ecd2b54/

Log:just print the pointer constant

diff --git a/rpython/jit/metainterp/compatible.py 
b/rpython/jit/metainterp/compatible.py
--- a/rpython/jit/metainterp/compatible.py
+++ b/rpython/jit/metainterp/compatible.py
@@ -294,7 +294,7 @@
 sid = 
self.metainterp_sd.cpu.get_actual_typeid(rffi.cast(llmemory.GCREF, 
llstr("abc")))
 if sid == tid:
 return hlstr(rffi.cast(lltype.Ptr(rstr.STR), 
arg.getref_base()))
-return ""
+return "0x%x" % lltype.cast_ptr_to_int(arg.value)
 else:
 return "None"
 elif isinstance(arg, ConstFloat):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy guard-compatible: fix translation

2016-09-20 Thread cfbolz
Author: Carl Friedrich Bolz 
Branch: guard-compatible
Changeset: r87249:3184d18e59b3
Date: 2016-08-26 15:02 +0100
http://bitbucket.org/pypy/pypy/changeset/3184d18e59b3/

Log:fix translation

diff --git a/rpython/jit/metainterp/compatible.py 
b/rpython/jit/metainterp/compatible.py
--- a/rpython/jit/metainterp/compatible.py
+++ b/rpython/jit/metainterp/compatible.py
@@ -317,6 +317,7 @@
 self.rpyfunc = op.rpyfunc
 
 def check_and_return_result_if_different(self, cpu, ref):
+from rpython.jit.metainterp.history import ConstInt
 calldescr = self.descr
 # change exactly the first argument
 arglist = self.args
@@ -329,7 +330,7 @@
 debug_print("call to elidable_compatible function raised")
 debug_print(self.repr())
 debug_stop("jit-guard-compatible")
-return False
+return ConstInt(41)
 finally:
 arglist[1] = None
 if not res.same_constant(self.res):
@@ -442,6 +443,7 @@
 qmut.register_loop_token(loop_token.loop_token_wref)
 
 def check_and_return_result_if_different(self, cpu, ref):
+from rpython.jit.metainterp.history import ConstInt
 from rpython.rlib.debug import debug_print, debug_start, debug_stop
 from rpython.jit.metainterp.quasiimmut import QuasiImmutDescr
 calldescr = self.descr
@@ -457,7 +459,7 @@
 debug_print("call to elidable_compatible function raised")
 debug_print(self.repr())
 debug_stop("jit-guard-compatible")
-return False
+return ConstInt(41)
 finally:
 arglist[1] = arglist[2] = None
 if not res.same_constant(self.res):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy ppc-vsx-support: merge default

2016-09-20 Thread plan_rich
Author: Richard Plangger 
Branch: ppc-vsx-support
Changeset: r87245:404ba62b0c60
Date: 2016-09-20 13:05 +0200
http://bitbucket.org/pypy/pypy/changeset/404ba62b0c60/

Log:merge default

diff --git a/lib-python/2.7/distutils/sysconfig_pypy.py 
b/lib-python/2.7/distutils/sysconfig_pypy.py
--- a/lib-python/2.7/distutils/sysconfig_pypy.py
+++ b/lib-python/2.7/distutils/sysconfig_pypy.py
@@ -63,8 +63,7 @@
 """Initialize the module as appropriate for POSIX systems."""
 g = {}
 g['EXE'] = ""
-g['SOABI'] = [s[0] for s in imp.get_suffixes() if s[2] == imp.C_EXTENSION]
-g['SO'] = g['SOABI'][0]
+g['SO'] = [s[0] for s in imp.get_suffixes() if s[2] == imp.C_EXTENSION][0]
 g['LIBDIR'] = os.path.join(sys.prefix, 'lib')
 g['CC'] = "gcc -pthread" # -pthread might not be valid on OS/X, check
 
@@ -76,8 +75,7 @@
 """Initialize the module as appropriate for NT"""
 g = {}
 g['EXE'] = ".exe"
-g['SOABI'] = [s[0] for s in imp.get_suffixes() if s[2] == imp.C_EXTENSION]
-g['SO'] = g['SOABI'][0]
+g['SO'] = [s[0] for s in imp.get_suffixes() if s[2] == imp.C_EXTENSION][0]
 
 global _config_vars
 _config_vars = g
diff --git a/lib-python/2.7/sysconfig.py b/lib-python/2.7/sysconfig.py
--- a/lib-python/2.7/sysconfig.py
+++ b/lib-python/2.7/sysconfig.py
@@ -526,7 +526,10 @@
 
 # PyPy:
 import imp
-_CONFIG_VARS['SOABI'] = [s[0] for s in imp.get_suffixes() if s[2] == 
imp.C_EXTENSION]
+for suffix, mode, type_ in imp.get_suffixes():
+if type_ == imp.C_EXTENSION:
+_CONFIG_VARS['SOABI'] = suffix.split('.')[1]
+break
 
 if args:
 vals = []
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
@@ -797,9 +797,7 @@
 class AA(object):
 __slots__ = ('a',)
 aa = AA()
-# the following line works on CPython >= 2.6 but not on PyPy.
-# but see below for more
-raises(TypeError, "aa.__class__ = A")
+aa.__class__ = A
 raises(TypeError, "aa.__class__ = object")
 class Z1(A):
 pass
@@ -861,9 +859,13 @@
 __slots__ = ['a', 'b']
 class Order2(object):
 __slots__ = ['b', 'a']
-# the following line works on CPython >= 2.6 but not on PyPy.
-# but see below for more
-raises(TypeError, "Order1().__class__ = Order2")
+Order1().__class__ = Order2
+
+# like CPython, the order of slot names doesn't matter
+x = Order1()
+x.a, x.b = 1, 2
+x.__class__ = Order2
+assert (x.a, x.b) == (1, 2)
 
 class U1(object):
 __slots__ = ['a', 'b']
@@ -873,10 +875,11 @@
 __slots__ = ['a', 'b']
 class V2(V1):
 __slots__ = ['c', 'd', 'e']
-# the following line does not work on CPython >= 2.6 either.
-# that's just obscure.  Really really.  So we just ignore
-# the whole issue until someone comes complaining.  Then we'll
-# just kill slots altogether apart from maybe doing a few checks.
+# the following line does not work on CPython either: we can't
+# change a class if the old and new class have different layouts
+# that look compatible but aren't, because they don't have the
+# same base-layout class (even if these base classes are
+# themselves compatible)...  obscure.
 raises(TypeError, "U2().__class__ = V2")
 
 def test_name(self):
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
@@ -102,9 +102,10 @@
 """
 _immutable_ = True
 
-def __init__(self, typedef, nslots, base_layout=None):
+def __init__(self, typedef, nslots, newslotnames=[], base_layout=None):
 self.typedef = typedef
 self.nslots = nslots
+self.newslotnames = newslotnames[:]# make a fixed-size list
 self.base_layout = base_layout
 
 def issublayout(self, parent):
@@ -114,6 +115,12 @@
 return False
 return True
 
+def expand(self, hasdict, weakrefable):
+"""Turn this Layout into a tuple.  If two classes get equal
+tuples, it means their instances have a fully compatible layout."""
+return (self.typedef, self.newslotnames, self.base_layout,
+hasdict, weakrefable)
+
 
 # possible values of compares_by_identity_status
 UNKNOWN = 0
@@ -289,8 +296,7 @@
 
 # compute a tuple that fully describes the instance layout
 def get_full_instance_layout(self):
-layout = self.layout
-return (layout, self.hasdict, self.weakrefable)
+return self.layout.expand(self.hasdict, self.weakrefable)
 
 def compute_default_mro(self):
 return 

[pypy-commit] pypy ppc-vsx-support: apply translation fixes for ppc

2016-09-20 Thread plan_rich
Author: Richard Plangger 
Branch: ppc-vsx-support
Changeset: r87244:8dcfbc70c92d
Date: 2016-09-20 13:04 +0200
http://bitbucket.org/pypy/pypy/changeset/8dcfbc70c92d/

Log:apply translation fixes for ppc

diff --git a/rpython/jit/backend/ppc/vector_ext.py 
b/rpython/jit/backend/ppc/vector_ext.py
--- a/rpython/jit/backend/ppc/vector_ext.py
+++ b/rpython/jit/backend/ppc/vector_ext.py
@@ -13,7 +13,7 @@
 from rpython.jit.backend.ppc.locations import imm, RegisterLocation
 from rpython.jit.backend.ppc.arch import IS_BIG_ENDIAN
 from rpython.jit.backend.llsupport.vector_ext import VectorExt
-from rpython.jit.backend.ppc.arch import PARAM_SAVE_AREA_OFFSET
+from rpython.jit.backend.ppc.arch import PARAM_SAVE_AREA_OFFSET, WORD
 import rpython.jit.backend.ppc.register as r
 import rpython.jit.backend.ppc.condition as c
 import rpython.jit.backend.ppc.locations as l
@@ -785,10 +785,12 @@
 arg = op.getarg(0)
 if arg.is_vector():
 srcloc = self.ensure_vector_reg(arg)
+assert isinstance(arg, VectorOp)
+size = arg.bytesize
 else:
 # unpack
-srcloc = self.ensure_reg(arg0)
-size = arg.bytesize
+srcloc = self.ensure_reg(arg)
+size = WORD
 if op.is_vector():
 resloc = self.force_allocate_vector_reg(op)
 else:
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: Replace checks for None and space.w_None with space.is_none

2016-09-20 Thread remarkablerocket
Author: Daniel Patrick 
Branch: py3.5
Changeset: r87242:3c6fe0885f72
Date: 2016-09-19 17:20 +0100
http://bitbucket.org/pypy/pypy/changeset/3c6fe0885f72/

Log:Replace checks for None and space.w_None with space.is_none

diff --git a/pypy/module/__builtin__/operation.py 
b/pypy/module/__builtin__/operation.py
--- a/pypy/module/__builtin__/operation.py
+++ b/pypy/module/__builtin__/operation.py
@@ -106,7 +106,7 @@
 if round is None:
 raise oefmt(space.w_TypeError,
 "type %T doesn't define __round__ method", w_number)
-if w_ndigits is None or w_ndigits is space.w_None:
+if space.is_none(w_ndigits):
 return space.get_and_call_function(round, w_number)
 else:
 return space.get_and_call_function(round, w_number, w_ndigits)
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: Implement round ndigits=None behaviour as per CPython 3.5 docs

2016-09-20 Thread remarkablerocket
Author: Daniel Patrick 
Branch: py3.5
Changeset: r87241:02d30675260e
Date: 2016-09-19 16:12 +0100
http://bitbucket.org/pypy/pypy/changeset/02d30675260e/

Log:Implement round ndigits=None behaviour as per CPython 3.5 docs

diff --git a/pypy/module/__builtin__/operation.py 
b/pypy/module/__builtin__/operation.py
--- a/pypy/module/__builtin__/operation.py
+++ b/pypy/module/__builtin__/operation.py
@@ -100,13 +100,13 @@
 """round(number[, ndigits]) -> number
 
 Round a number to a given precision in decimal digits (default 0 digits).
-This returns an int when called with one argument, otherwise the
-same type as the number. ndigits may be negative."""
+This returns an int when called with one argument or if ndigits=None,
+otherwise the same type as the number. ndigits may be negative."""
 round = space.lookup(w_number, '__round__')
 if round is None:
 raise oefmt(space.w_TypeError,
 "type %T doesn't define __round__ method", w_number)
-if w_ndigits is None:
+if w_ndigits is None or w_ndigits is space.w_None:
 return space.get_and_call_function(round, w_number)
 else:
 return space.get_and_call_function(round, w_number, w_ndigits)
diff --git a/pypy/module/__builtin__/test/test_builtin.py 
b/pypy/module/__builtin__/test/test_builtin.py
--- a/pypy/module/__builtin__/test/test_builtin.py
+++ b/pypy/module/__builtin__/test/test_builtin.py
@@ -814,8 +814,9 @@
 raises(TypeError, round, t)
 raises(TypeError, round, t, 0)
 
-raises(TypeError, round, 3, None)
-raises(TypeError, round, 3.0, None)
+assert round(3, ndigits=None) == 3
+assert round(3.0, ndigits=None) == 3
+assert type(round(3.0, ndigits=None)) is int
 
 def test_vars_obscure_case(self):
 class C_get_vars(object):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: Merged in remarkablerocket/pypy/py3.5 (pull request #480)

2016-09-20 Thread arigo
Author: Armin Rigo 
Branch: py3.5
Changeset: r87243:5f9c690d2444
Date: 2016-09-20 12:22 +0200
http://bitbucket.org/pypy/pypy/changeset/5f9c690d2444/

Log:Merged in remarkablerocket/pypy/py3.5 (pull request #480)

 Implement round ndigits=None behaviour as per CPython 3.5 docs

diff --git a/pypy/module/__builtin__/operation.py 
b/pypy/module/__builtin__/operation.py
--- a/pypy/module/__builtin__/operation.py
+++ b/pypy/module/__builtin__/operation.py
@@ -100,13 +100,13 @@
 """round(number[, ndigits]) -> number
 
 Round a number to a given precision in decimal digits (default 0 digits).
-This returns an int when called with one argument, otherwise the
-same type as the number. ndigits may be negative."""
+This returns an int when called with one argument or if ndigits=None,
+otherwise the same type as the number. ndigits may be negative."""
 round = space.lookup(w_number, '__round__')
 if round is None:
 raise oefmt(space.w_TypeError,
 "type %T doesn't define __round__ method", w_number)
-if w_ndigits is None:
+if space.is_none(w_ndigits):
 return space.get_and_call_function(round, w_number)
 else:
 return space.get_and_call_function(round, w_number, w_ndigits)
diff --git a/pypy/module/__builtin__/test/test_builtin.py 
b/pypy/module/__builtin__/test/test_builtin.py
--- a/pypy/module/__builtin__/test/test_builtin.py
+++ b/pypy/module/__builtin__/test/test_builtin.py
@@ -814,8 +814,9 @@
 raises(TypeError, round, t)
 raises(TypeError, round, t, 0)
 
-raises(TypeError, round, 3, None)
-raises(TypeError, round, 3.0, None)
+assert round(3, ndigits=None) == 3
+assert round(3.0, ndigits=None) == 3
+assert type(round(3.0, ndigits=None)) is int
 
 def test_vars_obscure_case(self):
 class C_get_vars(object):
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: Issue #2400: Rename the interp-level module to '_operator'

2016-09-20 Thread arigo
Author: Armin Rigo 
Branch: py3.5
Changeset: r87240:6524139cfc98
Date: 2016-09-20 12:08 +0200
http://bitbucket.org/pypy/pypy/changeset/6524139cfc98/

Log:Issue #2400: Rename the interp-level module to '_operator'

diff --git a/pypy/config/pypyoption.py b/pypy/config/pypyoption.py
--- a/pypy/config/pypyoption.py
+++ b/pypy/config/pypyoption.py
@@ -24,7 +24,7 @@
 default_modules = essential_modules.copy()
 default_modules.update([
 "_codecs", "atexit", "gc", "_weakref", "marshal", "errno", "imp",
-"itertools", "math", "cmath", "_sre", "_pickle_support", "operator",
+"itertools", "math", "cmath", "_sre", "_pickle_support", "_operator",
 "parser", "symbol", "token", "_ast", "_random", "__pypy__",
 "_string", "_testing", "time"
 ])
diff --git a/pypy/interpreter/app_main.py b/pypy/interpreter/app_main.py
--- a/pypy/interpreter/app_main.py
+++ b/pypy/interpreter/app_main.py
@@ -890,8 +890,8 @@
 import runpy
 if 'time' not in sys.builtin_module_names:
 import time; del time
-if 'operator' not in sys.builtin_module_names:
-import operator; del operator
+if '_operator' not in sys.builtin_module_names:
+import _operator; del _operator
 
 # no one should change to which lists sys.argv and sys.path are bound
 old_argv = sys.argv
diff --git a/pypy/module/operator/__init__.py b/pypy/module/operator/__init__.py
--- a/pypy/module/operator/__init__.py
+++ b/pypy/module/operator/__init__.py
@@ -2,6 +2,7 @@
 
 class Module(MixedModule):
 """Operator Builtin Module. """
+applevel_name = '_operator'
 
 # HACK! override loaders to be able to access different operations
 # under same name. I.e., operator.eq == operator.__eq__
diff --git a/pypy/module/operator/test/test_operator.py 
b/pypy/module/operator/test/test_operator.py
--- a/pypy/module/operator/test/test_operator.py
+++ b/pypy/module/operator/test/test_operator.py
@@ -1,12 +1,14 @@
 # -*- coding: utf-8 -*-
 
 class AppTestOperator:
+spaceconfig = dict(usemodules=['operator'])
+
 def test_equality(self):
-import operator
+import _operator as operator
 assert operator.eq == operator.__eq__
 
 def test_getters_are_not_regular_functions(self):
-import operator
+import _operator as operator
 class A(object):
 getx = operator.attrgetter('x')
 get3 = operator.itemgetter(3)
@@ -21,7 +23,7 @@
 assert l == ["x"]
 
 def test_getter_multiple_gest(self):
-import operator
+import _operator as operator
 
 class A(object):
 pass
@@ -40,11 +42,11 @@
 raises(TypeError, operator.itemgetter(2, 'x', 5), data)
 
 def test_attrgetter(self):
-import operator
+import _operator as operator
 raises(TypeError, operator.attrgetter, 2)
 
 def test_dotted_attrgetter(self):
-from operator import attrgetter
+from _operator import attrgetter
 class A:
 pass
 a = A()
@@ -56,7 +58,7 @@
 assert attrgetter("child.name", "child.foo")(a) == ("world", "bar")
 
 def test_attrgetter_type(self):
-from operator import attrgetter
+from _operator import attrgetter
 assert type(attrgetter("child.name")) is attrgetter
 
 def test_concat(self):
@@ -88,7 +90,7 @@
 def __rmul__(self, other):
 return other * self.lst
 
-import operator
+import _operator as operator
 
 raises(TypeError, operator.concat)
 raises(TypeError, operator.concat, None, None)
@@ -127,7 +129,7 @@
 def __rmul__(self, other):
 return other * self.lst
 
-import operator
+import _operator as operator
 
 a = list(range(3))
 raises(TypeError, operator.mul)
@@ -153,14 +155,14 @@
 assert operator.mul(a, 0) == []
 
 def test_iadd(self):
-import operator
+import _operator as operator
 
 list = []
 assert operator.iadd(list, [1, 2]) is list
 assert list == [1, 2]
 
 def test_imul(self):
-import operator
+import _operator as operator
 
 class X(object):
 def __index__(self):
@@ -176,7 +178,7 @@
 assert a == [0, 1, 2, 0, 1, 2]
 
 def test_methodcaller(self):
-from operator import methodcaller
+from _operator import methodcaller
 class X(object):
 def method(self, arg1=2, arg2=3):
 return arg1, arg2
@@ -187,7 +189,7 @@
 assert methodcaller("method", 4, arg2=42)(x) == (4, 42)
 
 def test_index(self):
-import operator
+import _operator as operator
 assert operator.index(42) == 42
 assert operator.__index__(42) == 42
 raises(TypeError, operator.index, "abc")
@@ -195,14 +197,14 @@
 assert str(exc.value) == "'str' object cannot be interpreted as an 
integer"
 
 def 

[pypy-commit] pypy ppc-vsx-support: use os.open instead of open() to read from /proc files at runtime

2016-09-20 Thread plan_rich
Author: Richard Plangger 
Branch: ppc-vsx-support
Changeset: r87239:d0e4fba9c670
Date: 2016-09-20 09:06 +0200
http://bitbucket.org/pypy/pypy/changeset/d0e4fba9c670/

Log:use os.open instead of open() to read from /proc files at runtime

diff --git a/rpython/jit/backend/ppc/detect_feature.py 
b/rpython/jit/backend/ppc/detect_feature.py
--- a/rpython/jit/backend/ppc/detect_feature.py
+++ b/rpython/jit/backend/ppc/detect_feature.py
@@ -1,3 +1,4 @@
+import os
 import sys
 import struct
 import platform
@@ -13,19 +14,25 @@
 SYSTEM = platform.system()
 
 def detect_vsx_linux():
-with open('/proc/self/auxv', 'rb') as fd:
-while True:
-buf = fd.read(8)
-buf2 = fd.read(8)
-if not buf or not buf2:
-break
-key = runpack("L", buf)
-value = runpack("L", buf2)
-if key == AT_HWCAP:
-if value & PPC_FEATURE_HAS_ALTIVEC:
-return True
-if key == AT_NULL:
-return False
+try:
+fd = os.open("/proc/self/auxv", os.O_RDONLY, 0644)
+try:
+while True:
+buf = os.read(fd, 8)
+buf2 = os.read(fd, 8)
+if not buf or not buf2:
+break
+key = runpack("L", buf)
+value = runpack("L", buf2)
+if key == AT_HWCAP:
+if value & PPC_FEATURE_HAS_ALTIVEC:
+return True
+if key == AT_NULL:
+return False
+finally:
+os.close(fd)
+except OSError:
+pass
 return False
 
 def detect_vsx():
diff --git a/rpython/jit/backend/x86/assembler.py 
b/rpython/jit/backend/x86/assembler.py
--- a/rpython/jit/backend/x86/assembler.py
+++ b/rpython/jit/backend/x86/assembler.py
@@ -693,7 +693,7 @@
 assert len(guard_locs) == len(bridge_locs)
 for i,src_loc in enumerate(guard_locs):
 dst_loc = bridge_locs[i]
-if not src_loc.is_fp_reg():
+if not src_loc.is_float():
 src_locations1.append(src_loc)
 dst_locations1.append(dst_loc)
 else:
diff --git a/rpython/jit/metainterp/optimizeopt/schedule.py 
b/rpython/jit/metainterp/optimizeopt/schedule.py
--- a/rpython/jit/metainterp/optimizeopt/schedule.py
+++ b/rpython/jit/metainterp/optimizeopt/schedule.py
@@ -128,7 +128,7 @@
 self.delay_emit(node)
 return
 # emit a now!
-self.pre_emit(node)
+self.pre_emit(node, True)
 self.mark_emitted(node)
 if not node.is_imaginary():
 op = node.getoperation()
diff --git a/rpython/translator/platform/arch/s390x.py 
b/rpython/translator/platform/arch/s390x.py
--- a/rpython/translator/platform/arch/s390x.py
+++ b/rpython/translator/platform/arch/s390x.py
@@ -1,4 +1,5 @@
 import re
+import os
 
 def extract_s390x_cpu_ids(lines):
 ids = []
@@ -39,20 +40,31 @@
 return ids
 
 def s390x_detect_vx():
-contentlist = []
-with open("/proc/cpuinfo", "rb") as fd:
-content = fd.read()
-start = content.find("features", 0)
-if start >= 0:
-after_colon = content.find(":", start)
-if after_colon < 0:
-return False
-newline = content.find("\n", after_colon)
-if newline < 0:
-return False
-split = content[after_colon+1:newline].strip().split(' ')
-if 'vx' in split:
-return True
+chunks = []
+try:
+fd = os.open("/proc/self/auxv", os.O_RDONLY, 0644)
+try:
+while True:
+chunk = os.read(fd, 4096)
+if not chunk:
+break
+chunks.append(chunk)
+finally:
+os.close(fd)
+except OSError:
+pass
+content = ''.join(chunks)
+start = content.find("features", 0)
+if start >= 0:
+after_colon = content.find(":", start)
+if after_colon < 0:
+return False
+newline = content.find("\n", after_colon)
+if newline < 0:
+return False
+split = content[after_colon+1:newline].strip().split(' ')
+if 'vx' in split:
+return True
 return False
 
 def s390x_cpu_revision():
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit