[numpy/f19] Rebase insecure-mktemp patch for 1.7.2

Orion Poplawski orion at fedoraproject.org
Mon Feb 10 22:22:54 UTC 2014


commit a7397d278b64d441a68ac5aba751347cb83d3fde
Author: Orion Poplawski <orion at nwra.com>
Date:   Mon Feb 10 15:23:32 2014 -0700

    Rebase insecure-mktemp patch for 1.7.2

 numpy-insecure-mktemp-use.patch |   96 ++++++++++++++++++---------------------
 numpy.spec                      |    2 +-
 2 files changed, 46 insertions(+), 52 deletions(-)
---
diff --git a/numpy-insecure-mktemp-use.patch b/numpy-insecure-mktemp-use.patch
index 08611a0..a905e6b 100644
--- a/numpy-insecure-mktemp-use.patch
+++ b/numpy-insecure-mktemp-use.patch
@@ -1,16 +1,10 @@
-@@ -, +, @@ 
----
- numpy/core/tests/test_memmap.py     | 34 ++++++++++++++++------------------
- numpy/core/tests/test_multiarray.py |  9 +++------
- numpy/f2py/__init__.py              | 26 +++++++++++++-------------
- numpy/f2py/f2py2e.py                |  4 ++--
- 4 files changed, 34 insertions(+), 39 deletions(-)
---- a/numpy/core/tests/test_memmap.py	
-+++ a/numpy/core/tests/test_memmap.py	
-@@ -1,5 +1,5 @@ 
+diff -up numpy-1.7.2/numpy/core/tests/test_memmap.py.tmpfile numpy-1.7.2/numpy/core/tests/test_memmap.py
+--- numpy-1.7.2/numpy/core/tests/test_memmap.py.tmpfile	2013-12-31 05:25:53.000000000 -0700
++++ numpy-1.7.2/numpy/core/tests/test_memmap.py	2014-02-10 15:22:39.856717349 -0700
+@@ -1,5 +1,5 @@
  import sys
--from tempfile import NamedTemporaryFile, mktemp
-+from tempfile import NamedTemporaryFile
+-from tempfile import NamedTemporaryFile, TemporaryFile, mktemp
++from tempfile import NamedTemporaryFile, TemporaryFile
  import os
  
  from numpy import memmap
@@ -30,9 +24,9 @@
 +            fp[:] = self.data[:]
 +            del fp
  
-     def test_attributes(self):
-         offset = 1
-@@ -48,17 +47,16 @@ class TestMemmap(TestCase):
+     def test_unnamed_file(self):
+         f =  TemporaryFile()
+@@ -54,17 +53,16 @@ class TestMemmap(TestCase):
          del fp
  
      def test_filename(self):
@@ -60,9 +54,10 @@
  
      def test_filename_fileobj(self):
          fp = memmap(self.tmpfp, dtype=self.dtype, mode="w+",
---- a/numpy/core/tests/test_multiarray.py	
-+++ a/numpy/core/tests/test_multiarray.py	
-@@ -1587,12 +1587,11 @@ class TestIO(object):
+diff -up numpy-1.7.2/numpy/core/tests/test_multiarray.py.tmpfile numpy-1.7.2/numpy/core/tests/test_multiarray.py
+--- numpy-1.7.2/numpy/core/tests/test_multiarray.py.tmpfile	2013-12-31 05:25:53.000000000 -0700
++++ numpy-1.7.2/numpy/core/tests/test_multiarray.py	2014-02-10 15:22:06.243908179 -0700
+@@ -1615,12 +1615,11 @@ class TestIO(object):
          self.x = rand(shape) + rand(shape).astype(np.complex)*1j
          self.x[0,:,1] = [nan, inf, -inf, nan]
          self.dtype = self.x.dtype
@@ -78,7 +73,7 @@
  
      def test_bool_fromstring(self):
          v = np.array([True,False,True,False], dtype=np.bool_)
-@@ -1620,7 +1619,6 @@ class TestIO(object):
+@@ -1648,7 +1647,6 @@ class TestIO(object):
          y = np.fromfile(f, dtype=self.dtype)
          f.close()
          assert_array_equal(y, self.x.flat)
@@ -86,7 +81,7 @@
  
      def test_roundtrip_filename(self):
          self.x.tofile(self.filename)
-@@ -1753,7 +1751,6 @@ class TestIO(object):
+@@ -1781,7 +1779,6 @@ class TestIO(object):
          s = f.read()
          f.close()
          assert_equal(s, '1.51,2.0,3.51,4.0')
@@ -94,8 +89,30 @@
  
      def test_tofile_format(self):
          x = np.array([1.51, 2, 3.51, 4], dtype=float)
---- a/numpy/f2py/__init__.py	
-+++ a/numpy/f2py/__init__.py	
+diff -up numpy-1.7.2/numpy/f2py/f2py2e.py.tmpfile numpy-1.7.2/numpy/f2py/f2py2e.py
+--- numpy-1.7.2/numpy/f2py/f2py2e.py.tmpfile	2013-12-31 05:25:53.000000000 -0700
++++ numpy-1.7.2/numpy/f2py/f2py2e.py	2014-02-10 15:22:06.244908173 -0700
+@@ -91,7 +91,7 @@ Options:
+                    --lower is assumed with -h key, and --no-lower without -h key.
+ 
+   --build-dir <dirname>  All f2py generated files are created in <dirname>.
+-                   Default is tempfile.mktemp().
++                   Default is tempfile.mkstemp().
+ 
+   --overwrite-signature  Overwrite existing signature file.
+ 
+@@ -428,7 +428,7 @@ def run_compile():
+         del sys.argv[i]
+     else:
+         remove_build_dir = 1
+-        build_dir = os.path.join(tempfile.mktemp())
++        build_dir = tempfile.mkdtemp()
+ 
+     sysinfo_flags = filter(re.compile(r'[-][-]link[-]').match,sys.argv[1:])
+     sys.argv = filter(lambda a,flags=sysinfo_flags:a not in flags,sys.argv)
+diff -up numpy-1.7.2/numpy/f2py/__init__.py.tmpfile numpy-1.7.2/numpy/f2py/__init__.py
+--- numpy-1.7.2/numpy/f2py/__init__.py.tmpfile	2013-12-31 05:25:53.000000000 -0700
++++ numpy-1.7.2/numpy/f2py/__init__.py	2014-02-10 15:22:06.244908173 -0700
 @@ -27,20 +27,20 @@ def compile(source,
      from numpy.distutils.exec_command import exec_command
      import tempfile
@@ -104,23 +121,21 @@
 +        f = tempfile.NamedTemporaryFile(suffix='.f')
      else:
 -        fname = source_fn
--
++        f = open(source_fn, 'w')
+ 
 -    f = open(fname,'w')
 -    f.write(source)
 -    f.close()
--
++    try:
++        f.write(source)
++        f.flush()
+ 
 -    args = ' -c -m %s %s %s'%(modulename,fname,extra_args)
 -    c = '%s -c "import numpy.f2py as f2py2e;f2py2e.main()" %s' %(sys.executable,args)
 -    s,o = exec_command(c)
 -    if source_fn is None:
 -        try: os.remove(fname)
 -        except OSError: pass
-+        f = open(source_fn, 'w')
-+
-+    try:
-+        f.write(source)
-+        f.flush()
-+
 +        args = ' -c -m %s %s %s'%(modulename, f.name, extra_args)
 +        c = '%s -c "import numpy.f2py as f2py2e;f2py2e.main()" %s' % \
 +                (sys.executable, args)
@@ -130,24 +145,3 @@
      return s
  
  from numpy.testing import Tester
---- a/numpy/f2py/f2py2e.py	
-+++ a/numpy/f2py/f2py2e.py	
-@@ -91,7 +91,7 @@ Options:
-                    --lower is assumed with -h key, and --no-lower without -h key.
- 
-   --build-dir <dirname>  All f2py generated files are created in <dirname>.
--                   Default is tempfile.mktemp().
-+                   Default is tempfile.mkstemp().
- 
-   --overwrite-signature  Overwrite existing signature file.
- 
-@@ -428,7 +428,7 @@ def run_compile():
-         del sys.argv[i]
-     else:
-         remove_build_dir = 1
--        build_dir = os.path.join(tempfile.mktemp())
-+        build_dir = tempfile.mkdtemp()
- 
-     sysinfo_flags = filter(re.compile(r'[-][-]link[-]').match,sys.argv[1:])
-     sys.argv = filter(lambda a,flags=sysinfo_flags:a not in flags,sys.argv)
--- 
diff --git a/numpy.spec b/numpy.spec
index 73aca4e..e53e396 100644
--- a/numpy.spec
+++ b/numpy.spec
@@ -101,7 +101,7 @@ This package includes a version of f2py that works properly with NumPy.
 
 %prep
 %setup -q -n %{name}-%{version}%{?relc}
-%patch0 -p1
+%patch0 -p1 -b .tmpfile
 %patch1 -p1
 # workaround for rhbz#849713
 # http://mail.scipy.org/pipermail/numpy-discussion/2012-July/063530.html


More information about the scm-commits mailing list