View | Details | Raw Unified | Return to bug 200699
Collapse All | Expand All

(-)Makefile (-2 / +1 lines)
Lines 2-9 Link Here
2
# $FreeBSD$
2
# $FreeBSD$
3
3
4
PORTNAME=	cffi
4
PORTNAME=	cffi
5
PORTVERSION=	0.8.6
5
PORTVERSION=	1.1.1
6
PORTREVISION=	3
7
CATEGORIES=	devel python
6
CATEGORIES=	devel python
8
MASTER_SITES=	CHEESESHOP
7
MASTER_SITES=	CHEESESHOP
9
PKGNAMEPREFIX=	${PYTHON_PKGNAMEPREFIX}
8
PKGNAMEPREFIX=	${PYTHON_PKGNAMEPREFIX}
(-)distinfo (-2 / +2 lines)
Lines 1-2 Link Here
1
SHA256 (cffi-0.8.6.tar.gz) = 2532d9e3af9e3c6d0f710fc98b0295b563c7f39cfd97dd2242bd36fbf4900610
1
SHA256 (cffi-1.1.1.tar.gz) = 81fbaf121a67a0c4d390cc0ce7a69661f987f5cf34997575131e8a1bbe1ee1c6
2
SIZE (cffi-0.8.6.tar.gz) = 196835
2
SIZE (cffi-1.1.1.tar.gz) = 326663
(-)files/patch-cffi_verifier.py (-68 lines)
Lines 1-68 Link Here
1
# Backport: PR #56: Actually check if the file exists rather than assume it doesn't
2
# https://bitbucket.org/cffi/cffi/pull-request/56/
3
4
--- cffi/verifier.py.orig	2015-02-11 08:57:05 UTC
5
+++ cffi/verifier.py
6
@@ -1,7 +1,16 @@
7
-import sys, os, binascii, imp, shutil
8
+import sys, os, binascii, imp, shutil, io
9
 from . import __version__
10
 from . import ffiplatform
11
 
12
+if sys.version_info >= (3,):
13
+    NativeIO = io.StringIO
14
+else:
15
+    class NativeIO(io.BytesIO):
16
+        def write(self, s):
17
+            if isinstance(s, unicode):
18
+                s = s.encode('ascii')
19
+            super(NativeIO, self).write(s)
20
+
21
 
22
 class Verifier(object):
23
 
24
@@ -118,19 +127,36 @@ class Verifier(object):
25
         self._vengine.collect_types()
26
         self._has_module = True
27
 
28
-    def _write_source(self, file=None):
29
-        must_close = (file is None)
30
-        if must_close:
31
-            _ensure_dir(self.sourcefilename)
32
-            file = open(self.sourcefilename, 'w')
33
+    def _write_source_to(self, file):
34
         self._vengine._f = file
35
         try:
36
             self._vengine.write_source_to_f()
37
         finally:
38
             del self._vengine._f
39
-            if must_close:
40
-                file.close()
41
-        if must_close:
42
+
43
+    def _write_source(self, file=None):
44
+        if file is not None:
45
+            self._write_source_to(file)
46
+        else:
47
+            # Write our source file to an in memory file.
48
+            f = NativeIO()
49
+            self._write_source_to(f)
50
+            source_data = f.getvalue()
51
+
52
+            # Determine if this matches the current file
53
+            if os.path.exists(self.sourcefilename):
54
+                with open(self.sourcefilename, "r") as fp:
55
+                    needs_written = not (fp.read() == source_data)
56
+            else:
57
+                needs_written = True
58
+
59
+            # Actually write the file out if it doesn't match
60
+            if needs_written:
61
+                _ensure_dir(self.sourcefilename)
62
+                with open(self.sourcefilename, "w") as fp:
63
+                    fp.write(source_data)
64
+
65
+            # Set this flag
66
             self._has_source = True
67
 
68
     def _compile_module(self):

Return to bug 200699