[Python-modules-commits] [dill] 01/07: Import dill_0.2.7.1.orig.tar.gz

Josué Ortega josue at moszumanska.debian.org
Sun Aug 13 02:52:13 UTC 2017


This is an automated email from the git hooks/post-receive script.

josue pushed a commit to branch master
in repository dill.

commit abcaa3a469de4441af8477f28716bc19c2351e6c
Author: Josue Ortega <josue at debian.org>
Date:   Sat Aug 12 19:27:35 2017 -0400

    Import dill_0.2.7.1.orig.tar.gz
---
 README                  |  6 +++---
 dill.egg-info/PKG-INFO  |  8 ++++----
 dill/__diff.py          |  8 +++++---
 dill/_objects.py        |  3 ++-
 dill/dill.py            | 40 +++++++++++++++++++++-------------------
 dill/info.py            | 10 +++++-----
 setup.py                |  6 +++---
 tests/test_recursive.py | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 8 files changed, 92 insertions(+), 38 deletions(-)

diff --git a/README b/README
index bba6495..7866e44 100644
--- a/README
+++ b/README
@@ -67,7 +67,7 @@ Major Features
 Current Release
 ===============
 
-This version is `dill-0.2.7`.
+This version is `dill-0.2.7.1`.
 
 The latest released version of `dill` is available from::
 
@@ -104,8 +104,8 @@ Installation
 download the tarball, unzip, and run the installer::
 
     [download]
-    $ tar -xvzf dill-0.2.7.tgz
-    $ cd dill-0.2.7
+    $ tar -xvzf dill-0.2.7.1.tar.gz
+    $ cd dill-0.2.7.1
     $ python setup py build
     $ python setup py install
 
diff --git a/dill.egg-info/PKG-INFO b/dill.egg-info/PKG-INFO
index 3f664cf..58a6cac 100644
--- a/dill.egg-info/PKG-INFO
+++ b/dill.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: dill
-Version: 0.2.7
+Version: 0.2.7.1
 Summary: serialize all of python
 Home-page: http://www.cacr.caltech.edu/~mmckerns/dill.htm
 Author: Mike McKerns
@@ -76,7 +76,7 @@ Description: -----------------------------
         Current Release
         ===============
         
-        This version is `dill-0.2.7`.
+        This version is `dill-0.2.7.1`.
         
         The latest released version of `dill` is available from::
         
@@ -113,8 +113,8 @@ Description: -----------------------------
         download the tarball, unzip, and run the installer::
         
             [download]
-            $ tar -xvzf dill-0.2.7.tgz
-            $ cd dill-0.2.7
+            $ tar -xvzf dill-0.2.7.1.tar.gz
+            $ cd dill-0.2.7.1
             $ python setup py build
             $ python setup py install
         
diff --git a/dill/__diff.py b/dill/__diff.py
index c335cd0..4762280 100644
--- a/dill/__diff.py
+++ b/dill/__diff.py
@@ -118,7 +118,9 @@ def memorise(obj, force=False):
             [(mem(key), mem(item))
              for key, item in s.items()]
         else:
-            [mem(item) for item in s]
+            if hasattr(s, '__len__'):
+                [mem(item) for item in s]
+            else: mem(s)
 
 
 def release_gone():
@@ -182,9 +184,9 @@ def whats_changed(obj, seen=None, simple=False, first=True):
     # compare sequence
     items = get_seq(obj)
     seq_diff = False
-    if items is not None:
+    if (items is not None) and (hasattr(items, '__len__')):
         obj_seq = memo[obj_id][1]
-        if len(items) != len(obj_seq):
+        if (len(items) != len(obj_seq)):
             seq_diff = True
         elif hasattr(obj, "items"):  # dict type obj
             obj_get = obj_seq.get
diff --git a/dill/_objects.py b/dill/_objects.py
index af5f18a..2c49cee 100644
--- a/dill/_objects.py
+++ b/dill/_objects.py
@@ -216,7 +216,8 @@ if HAS_CTYPES:
     a['CSizeTType'] = ctypes.c_size_t()
     a['CLibraryLoaderType'] = ctypes.cdll
     a['StructureType'] = _Struct
-    a['BigEndianStructureType'] = ctypes.BigEndianStructure()
+    if not IS_PYPY:
+        a['BigEndianStructureType'] = ctypes.BigEndianStructure()
 #NOTE: also LittleEndianStructureType and UnionType... abstract classes
 #NOTE: remember for ctypesobj.contents creates a new python object
 #NOTE: ctypes.c_int._objects is memberdescriptor for object's __dict__
diff --git a/dill/dill.py b/dill/dill.py
index 5f3d801..8a4b387 100644
--- a/dill/dill.py
+++ b/dill/dill.py
@@ -29,13 +29,15 @@ def _trace(boolean):
     else: log.setLevel(logging.WARN)
     return
 
-stack = set()  # record of 'recursion-sensitive' pickled objects
+stack = dict()  # record of 'recursion-sensitive' pickled objects
 
 import os
 import sys
 diff = None
 _use_diff = False
 PY3 = (sys.hexversion >= 0x30000f0)
+# OLDER: 3.0 <= x < 3.4 *OR* x < 2.7.10  #NOTE: guessing relevant versions
+OLDER = (PY3 and sys.hexversion < 0x30400f0) or (sys.hexversion < 0x2070af0)
 if PY3: #XXX: get types from .objtypes ?
     import builtins as __builtin__
     from pickle import _Pickler as StockPickler, Unpickler as StockUnpickler
@@ -845,7 +847,7 @@ def save_module_dict(pickler, obj):
         else:
             pickler.write('c__builtin__\n__main__\n')
         log.info("# D1")
-    elif not is_dill(pickler) and obj == _main_module.__dict__:
+    elif (not is_dill(pickler)) and (obj == _main_module.__dict__):
         log.info("D3: <dict%s" % str(obj.__repr__).split('dict')[-1]) # obj
         if PY3:
             pickler.write(bytes('c__main__\n__dict__\n', 'UTF-8'))
@@ -872,7 +874,7 @@ def save_module_dict(pickler, obj):
 
 @register(ClassType)
 def save_classobj(pickler, obj): #FIXME: enable pickler._byref
-   #stack.add(id(obj))
+   #stack[id(obj)] = len(stack), obj
     if obj.__module__ == '__main__': #XXX: use _main_module.__name__ everywhere?
         log.info("C1: %s" % obj)
         pickler.save_reduce(ClassType, (obj.__name__, obj.__bases__,
@@ -1244,7 +1246,7 @@ def save_module(pickler, obj):
 
 @register(TypeType)
 def save_type(pickler, obj):
-   #stack.add(id(obj)) #XXX: probably don't need object from all cases below
+   #stack[id(obj)] = len(stack), obj #XXX: probably don't obj in all cases below
     if obj in _typemap:
         log.info("T1: %s" % obj)
         pickler.save_reduce(_load_type, (_typemap[obj],), obj=obj)
@@ -1339,32 +1341,32 @@ def save_function(pickler, obj):
             globs = obj.__globals__ if PY3 else obj.func_globals
         _byref = getattr(pickler, '_byref', None)
         _recurse = getattr(pickler, '_recurse', None)
-        _memo = not IS_PYPY and id(obj) in stack and _recurse is not None
-        #print("stack: %s + '%s'" % (set(hex(i) for i in stack),hex(id(obj))))
-        if not IS_PYPY: stack.add(id(obj))
+        _memo = (id(obj) in stack) and (_recurse is not None)
+       #print("stack: %s + '%s'" % (set(hex(i) for i in stack),hex(id(obj))))
+        stack[id(obj)] = len(stack), obj
         if PY3:
             #NOTE: workaround for 'super' (see issue #75)
-            _super = not IS_PYPY and 'super' in obj.__code__.co_names and _byref is not None
-            if _super or _memo:
-                if _super is not None: pickler._byref = True
-                if _memo is not None: pickler._recurse = False
+            _super = ('super' in getattr(obj.__code__,'co_names',())) and (_byref is not None)
+            if _super: pickler._byref = True
+            if _memo: pickler._recurse = False
             pickler.save_reduce(_create_function, (obj.__code__,
                                 globs, obj.__name__,
                                 obj.__defaults__, obj.__closure__,
                                 obj.__dict__), obj=obj)
         else:
-            _super = not IS_PYPY and 'super' in obj.func_code.co_names and _byref is not None and getattr(pickler, '_recurse', False)
-            if _super or _memo:
-                if _super is not None: pickler._byref = True
-                if _memo is not None: pickler._recurse = False
+            _super = ('super' in getattr(obj.func_code,'co_names',())) and (_byref is not None) and getattr(pickler, '_recurse', False)
+            if _super: pickler._byref = True
+            if _memo: pickler._recurse = False
             pickler.save_reduce(_create_function, (obj.func_code,
                                 globs, obj.func_name,
                                 obj.func_defaults, obj.func_closure,
                                 obj.__dict__), obj=obj)
-        if _super or _memo:
-            if _super is not None: pickler._byref = _byref
-            if _memo is not None: pickler._recurse = _recurse
-        if not IS_PYPY: pickler.clear_memo()
+        if _super: pickler._byref = _byref
+        if _memo: pickler._recurse = _recurse
+       #clear = (_byref, _super, _recurse, _memo)
+       #print(clear + (OLDER,))
+        #NOTE: workaround for #234; "partial" still is problematic for recurse
+        if OLDER and not _byref and (_super or (not _super and _memo) or (not _super and not _memo and _recurse)): pickler.clear_memo()
        #if _memo:
        #    stack.remove(id(obj))
        #   #pickler.clear_memo()
diff --git a/dill/info.py b/dill/info.py
index 47bf519..c4cb328 100644
--- a/dill/info.py
+++ b/dill/info.py
@@ -1,6 +1,6 @@
 # THIS FILE GENERATED FROM SETUP.PY
-this_version = '0.2.7'
-stable_version = '0.2.7'
+this_version = '0.2.7.1'
+stable_version = '0.2.7.1'
 readme = '''-----------------------------
 dill: serialize all of python
 -----------------------------
@@ -70,7 +70,7 @@ Major Features
 Current Release
 ===============
 
-This version is `dill-0.2.7`.
+This version is `dill-0.2.7.1`.
 
 The latest released version of `dill` is available from::
 
@@ -107,8 +107,8 @@ Installation
 download the tarball, unzip, and run the installer::
 
     [download]
-    $ tar -xvzf dill-0.2.7.tgz
-    $ cd dill-0.2.7
+    $ tar -xvzf dill-0.2.7.1.tar.gz
+    $ cd dill-0.2.7.1
     $ python setup py build
     $ python setup py install
 
diff --git a/setup.py b/setup.py
index 85a802d..b80a244 100644
--- a/setup.py
+++ b/setup.py
@@ -10,8 +10,8 @@ from __future__ import with_statement, absolute_import
 import os
 
 # set version numbers
-stable_version = '0.2.7'
-target_version = '0.2.7'
+stable_version = '0.2.7.1'
+target_version = '0.2.7.1'
 is_release = stable_version == target_version
 
 # check if easy_install is available
@@ -154,7 +154,7 @@ Installation
 download the tarball, unzip, and run the installer::
 
     [download]
-    $ tar -xvzf dill-%(thisver)s.tgz
+    $ tar -xvzf dill-%(thisver)s.tar.gz
     $ cd dill-%(thisver)s
     $ python setup py build
     $ python setup py install
diff --git a/tests/test_recursive.py b/tests/test_recursive.py
index a209d85..9672283 100644
--- a/tests/test_recursive.py
+++ b/tests/test_recursive.py
@@ -1,4 +1,6 @@
 import dill
+from functools import partial
+from dill.dill import PY3, OLDER
 _super = super
 
 class obj1(object):
@@ -32,5 +34,52 @@ def test_super():
     assert dill.copy(obj3())
 
 
+def get_trigger(model):
+    pass
+
+class Machine(object):
+    def __init__(self):
+        self.child = Model()
+        self.trigger = partial(get_trigger, self)
+        self.child.trigger = partial(get_trigger, self.child)
+
+class Model(object):
+    pass
+
+
+
+def test_partial():
+    assert dill.copy(Machine(), byref=True)
+    assert dill.copy(Machine(), byref=True, recurse=True)
+    if not OLDER:
+        assert dill.copy(Machine(), recurse=True)
+    assert dill.copy(Machine())
+
+
+class Machine2(object):
+    def __init__(self):
+        self.go = partial(self.member, self)
+    def member(self, model):
+        pass
+
+
+class SubMachine(Machine2):
+    def __init__(self):
+        _super(SubMachine, self).__init__()
+        #super(SubMachine, self).__init__() #XXX: works, except for 3.1-3.3
+
+
+def test_partials():
+    assert dill.copy(SubMachine(), byref=True)
+    assert dill.copy(SubMachine(), byref=True, recurse=True)
+    if not OLDER:
+        assert dill.copy(SubMachine(), recurse=True)
+    assert dill.copy(SubMachine())
+
+
+
 if __name__ == '__main__':
+    #print(('byref','_super','_recurse','_memo','_stop','OLDER'))
     test_super()
+    test_partial()
+    test_partials()

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/dill.git



More information about the Python-modules-commits mailing list