[python-guppy] Two fixes, backported from upstream's trunk

Peter Lemenkov peter at fedoraproject.org
Sat Mar 5 09:31:38 UTC 2011


commit 7b573daea5e3784c6bc80a745a1b93106b96b6c7
Author: Peter Lemenkov <lemenkov at gmail.com>
Date:   Sat Mar 5 12:30:42 2011 +0300

    Two fixes, backported from upstream's trunk
    
    - Fixed work on BigEndian arches
    - Fix for rhbz #679422 (backported from upstream's trunk
    
    Signed-off-by: Peter Lemenkov <lemenkov at gmail.com>

 python-guppy-0001-Work-with-big-endian-archs.patch |  116 ++++++++++++++++++++
 ...-changes-to-cope-with-Python-version-2.7-.patch |  109 ++++++++++++++++++
 python-guppy.spec                                  |   12 ++-
 3 files changed, 236 insertions(+), 1 deletions(-)
---
diff --git a/python-guppy-0001-Work-with-big-endian-archs.patch b/python-guppy-0001-Work-with-big-endian-archs.patch
new file mode 100644
index 0000000..182679d
--- /dev/null
+++ b/python-guppy-0001-Work-with-big-endian-archs.patch
@@ -0,0 +1,116 @@
+From 928398014a407c5728af44b57c4d9fe9994376f4 Mon Sep 17 00:00:00 2001
+From: Sverker Nilsson <sn at sncs.se>
+Date: Sun, 14 Feb 2010 11:24:42 +0000
+Subject: [PATCH 1/2] Work with big endian archs
+
+git-svn-id: https://guppy-pe.svn.sourceforge.net/svnroot/guppy-pe/trunk/guppy@83 a2a17790-8729-0410-921b-93eeb8b3d4a2
+
+In latest patch to src/sets/bitset.c (mutbitset_iop_PyLongObject) changed typo of pos from int to NyBit to handle very large objects in 64-bits mode
+
+git-svn-id: https://guppy-pe.svn.sourceforge.net/svnroot/guppy-pe/trunk/guppy@84 a2a17790-8729-0410-921b-93eeb8b3d4a2
+---
+ ChangeLog         |   11 +++++++++++
+ src/sets/bitset.c |   16 ++++++++++++++--
+ src/sets/bitset.h |   26 ++++++++++++++++++++++++++
+ 3 files changed, 51 insertions(+), 2 deletions(-)
+
+diff --git a/ChangeLog b/ChangeLog
+index 55aecfd..bbc851c 100644
+--- a/ChangeLog
++++ b/ChangeLog
+@@ -1,3 +1,14 @@
++2010-02-14  Sverker Nilsson  <sverker at sverker-laptop>
++	* src/sets/bitset.c (mutbitset_iop_PyLongObject): 
++	In the latest change where a loop over pos was added, changed type
++	from int to NyBit.
++	
++	* src/sets/bitset.h: Checks endianness and defines macros to
++	handle it.
++	* src/sets/bitset.c (immbitset_long): 
++	* src/sets/bitset.c (mutbitset_iop_PyLongObject): 
++	Changes to work with big endian.
++
+ 2009-06-23  Sverker Nilsson  <sverker at sverker-laptop>
+ 
+ 	* specs/index.gsl: download mentions today's date
+diff --git a/src/sets/bitset.c b/src/sets/bitset.c
+index 41dbdd5..2a9d6c0 100644
+--- a/src/sets/bitset.c
++++ b/src/sets/bitset.c
+@@ -2050,6 +2050,15 @@ mutbitset_iop_PyLongObject(NyMutBitSetObject *ms, int op, PyObject *v)
+ 			1, /* little_endian */
+ 			0  /* is_signed */);
+     if (r == -1) goto Err1;
++#if NyBits_IS_BIG_ENDIAN
++    {
++	NyBit pos;
++	for (pos = 0; pos < num_poses; pos++) {
++	    buf[pos] = NyBits_BSWAP(buf[pos]);
++	}
++    }
++#endif
++
+     r = mutbitset_iop_bits(ms, op, 0, buf, num_poses);
+     if (!r && cpl)
+       r = mutbitset_iop_complement(ms);
+@@ -3126,7 +3135,10 @@ immbitset_long(NyImmBitSetObject *v)
+     }
+     for (pos = 0; pos < num_poses; pos++) {
+ 	if (pos == f->pos) {
+-	    bits = f->bits;		/* xxx may want to byte-swap here */
++	    bits = f->bits;
++#if NyBits_IS_BIG_ENDIAN
++	    bits = NyBits_BSWAP(bits);
++#endif
+ 	    f++;
+ 	} else {
+ 	    bits = NyBits_EMPTY;
+@@ -3135,7 +3147,7 @@ immbitset_long(NyImmBitSetObject *v)
+     }
+     r = _PyLong_FromByteArray((unsigned char *)buf,		/* bytes */
+ 			      num_poses * sizeof(NyBits),	/* n = number of bytes*/
+-			      1,	/* Always little endian here (xxx?) */
++			      1,	/* Always little endian here */
+ 			      0);	/* not is_signed, never here */
+     PyMem_Del(buf);
+     return r;
+diff --git a/src/sets/bitset.h b/src/sets/bitset.h
+index 7fe3e82..cc05f47 100644
+--- a/src/sets/bitset.h
++++ b/src/sets/bitset.h
+@@ -32,6 +32,32 @@ typedef unsigned long NyBits;
+ #endif
+ 
+ 
++/* Assume __BYTE_ORDER is defined on all big-endian archs and that they
++   have byteswap.h. Little-endian archs don't include byteswap.h, so
++   it should still work with eg MSC.
++*/
++
++#ifdef __BYTE_ORDER
++#if __BYTE_ORDER==__BIG_ENDIAN
++
++#define NyBits_IS_BIG_ENDIAN 1
++
++#include "byteswap.h"
++
++#if (NyBits_N==64)
++#define NyBits_BSWAP(x) bswap_64(x)
++#elif (NyBits_N==32)
++#define NyBits_BSWAP(x) bswap_32(x)
++#else
++#error "Unsupported NyBits_N"
++#endif
++
++#endif
++#endif
++
++
++
++
+ typedef Py_intptr_t NyBit;
+ 
+ /* Largest positive value of type NyBit. */
+-- 
+1.7.4
+
diff --git a/python-guppy-0002-Preliminary-changes-to-cope-with-Python-version-2.7-.patch b/python-guppy-0002-Preliminary-changes-to-cope-with-Python-version-2.7-.patch
new file mode 100644
index 0000000..66e1135
--- /dev/null
+++ b/python-guppy-0002-Preliminary-changes-to-cope-with-Python-version-2.7-.patch
@@ -0,0 +1,109 @@
+From d1b05672d94d95fd2dfe2fc048017ead66f3eace Mon Sep 17 00:00:00 2001
+From: Sverker Nilsson <sn at sncs.se>
+Date: Tue, 8 Jun 2010 17:17:00 +0000
+Subject: [PATCH 2/2] Preliminary changes to cope with Python version 2.7; seems to work but is slower (10 times so in test ClassificationCase)
+
+git-svn-id: https://guppy-pe.svn.sourceforge.net/svnroot/guppy-pe/trunk/guppy@87 a2a17790-8729-0410-921b-93eeb8b3d4a2
+
+modification for python 2.7
+
+git-svn-id: https://guppy-pe.svn.sourceforge.net/svnroot/guppy-pe/trunk/guppy@88 a2a17790-8729-0410-921b-93eeb8b3d4a2
+---
+ guppy/heapy/test/test_Part.py |   14 +++++++++++---
+ guppy/sets/test.py            |    2 +-
+ src/sets/bitset.c             |   21 +++++++++++++++++----
+ 3 files changed, 29 insertions(+), 8 deletions(-)
+
+diff --git a/guppy/heapy/test/test_Part.py b/guppy/heapy/test/test_Part.py
+index 278a3fb..d8c2784 100644
+--- a/guppy/heapy/test/test_Part.py
++++ b/guppy/heapy/test/test_Part.py
+@@ -88,16 +88,24 @@ Set of 100 <float> objects. Total size = 1600 bytes.
+ 
+ class MixedCase(support.TestCase):
+     def test_1(self):
++        import sys
+ 	x = self.iso(1, 2, 1.0, 2.0, '1', '2')
+ 	if self.allocation_behaves_as_originally:
+-	    self.aseq(str(x), """\
++            if sys.version < '2.7':
++                self.aseq(str(x), """\
+ Partition of a set of 6 objects. Total size = 112 bytes.
+  Index  Count   %     Size   % Cumulative  % Kind (class / dict of class)
+      0      2  33       56  50        56  50 str
+      1      2  33       32  29        88  79 float
+      2      2  33       24  21       112 100 int""")
+-
+-
++            else:
++                self.aseq(str(x), """\
++Partition of a set of 6 objects. Total size = 104 bytes.
++ Index  Count   %     Size   % Cumulative  % Kind (class / dict of class)
++     0      2  33       48  46        48  46 str
++     1      2  33       32  31        80  77 float
++     2      2  33       24  23       104 100 int""")
++                
+ 	for row in x.partition.get_rows():
+ 	    self.assert_(row.set <= row.kind)
+ 	 
+diff --git a/guppy/sets/test.py b/guppy/sets/test.py
+index c6ae676..1afcbdf 100644
+--- a/guppy/sets/test.py
++++ b/guppy/sets/test.py
+@@ -892,7 +892,7 @@ MutBitSet([])
+ 	    except OverflowError:
+ 		pass
+ 	    else:
+-		raise 'expected ValueError'
++		raise 'expected OverflowError'
+ 
+ 	tsv(bitset([maxint]), 1)
+ 	tsv(bitset([minint]), -1)
+diff --git a/src/sets/bitset.c b/src/sets/bitset.c
+index 2a9d6c0..9ef46ab 100644
+--- a/src/sets/bitset.c
++++ b/src/sets/bitset.c
+@@ -2017,7 +2017,11 @@ mutbitset_iop_PyLongObject(NyMutBitSetObject *ms, int op, PyObject *v)
+     int cpl = 0;
+     PyObject *w = 0;
+     
+-    x = _PyLong_AsScaledDouble(v, &e);
++#if PY_VERSION_HEX >= 0x02070000
++	x = _PyLong_Frexp(v, &e);
++#else
++	x = _PyLong_AsScaledDouble(v, &e);
++#endif
+     if (x == -1 && PyErr_Occurred())
+       return -1;
+     if (x < 0) {
+@@ -2026,15 +2030,24 @@ mutbitset_iop_PyLongObject(NyMutBitSetObject *ms, int op, PyObject *v)
+ 	w = PyNumber_Invert(v);
+ 	if (!w) return -1;
+ 	v = w;
++#if PY_VERSION_HEX >= 0x02070000
++	x = _PyLong_Frexp(v, &e);
++#else
+ 	x = _PyLong_AsScaledDouble(v, &e);
++#endif
+ 	if (x == -1 && PyErr_Occurred())
+ 	  return -1;
+ 	assert(x >= 0);
+     }
+-    if (x != 0)
+-      num_bits = 1.0 * e * SHIFT + log(x)/log(2) + 1;
++    if (x != 0) {
++	num_bits = e;
++#if PY_VERSION_HEX < 0x02070000
++	num_bits *= SHIFT;
++#endif
++	num_bits += log(x)/log(2) + 1;
++    }
+     else
+-      num_bits = 0;
++	num_bits = 0;
+ 	
+     num_poses = (long)(num_bits / NyBits_N + 1);
+     /* fprintf(stderr, "x %f e %d num_bits %f num_poses %ld\n", x, e, num_bits, num_poses); */
+-- 
+1.7.4
+
diff --git a/python-guppy.spec b/python-guppy.spec
index 68f503e..0b78132 100644
--- a/python-guppy.spec
+++ b/python-guppy.spec
@@ -6,12 +6,16 @@
 
 Name:		python-%{realname}
 Version:	0.1.9
-Release:	3%{?dist}
+Release:	4%{?dist}
 Summary:	A Python Programming Environment
 Group:		Development/Languages
 License:	MIT
 URL:		http://guppy-pe.sourceforge.net/
 Source0:	http://pypi.python.org/packages/source/g/%{realname}/%{realname}-%{version}.tar.gz
+# Backported from upstream
+Patch1:		python-guppy-0001-Work-with-big-endian-archs.patch
+# Backported from upstream
+Patch2:		python-guppy-0002-Preliminary-changes-to-cope-with-Python-version-2.7-.patch
 BuildRoot:	%(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
 BuildRequires:	python-devel
 BuildRequires:	python-setuptools-devel
@@ -29,6 +33,8 @@ documentation from a common source.
 
 %prep
 %setup -q -n %{realname}-%{version}
+%patch1 -p1 -b .bigendian
+%patch2 -p1 -b .py27
 
 
 %build
@@ -52,6 +58,10 @@ rm -rf $RPM_BUILD_ROOT
 
 
 %changelog
+* Sat Mar 05 2011 Peter Lemenkov <lemenkov at gmail.com> -  0.1.9-4
+- Fixed work on BigEndian arches
+- Fix for rhbz #679422 (backported from upstream's trunk)
+
 * Tue Feb 08 2011 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 0.1.9-3
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild
 


More information about the scm-commits mailing list