]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Note: I'm merging these changes out of consistency, but they don't seem
authorAntoine Pitrou <solipsis@pitrou.net>
Wed, 13 Jan 2010 12:04:20 +0000 (12:04 +0000)
committerAntoine Pitrou <solipsis@pitrou.net>
Wed, 13 Jan 2010 12:04:20 +0000 (12:04 +0000)
to be needed in py3k (except perhaps for non-utf8 paths).

Merged revisions 77466-77467 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r77466 | antoine.pitrou | 2010-01-13 12:47:49 +0100 (mer., 13 janv. 2010) | 5 lines

  Issue #7661: Allow ctypes to be built from a non-ASCII directory path.
  Patch by Florent Xicluna.
........
  r77467 | antoine.pitrou | 2010-01-13 12:57:42 +0100 (mer., 13 janv. 2010) | 3 lines

  Use `with`
........

Modules/_ctypes/libffi/fficonfig.py.in
setup.py

index 10293273588b1be8ccbfd0b4fec931af5123e389..045d7c3b8d9445440ebd9ef1f03ea043b5c2db2d 100644 (file)
@@ -28,8 +28,6 @@ ffi_platforms = {
     'PA_HPUX': ['src/pa/hpux32.S', 'src/pa/ffi.c'],
 }
 
-ffi_srcdir = '@srcdir@'
 ffi_sources += ffi_platforms['@TARGET@']
-ffi_sources = [os.path.join('@srcdir@', f) for f in ffi_sources]
 
 ffi_cflags = '@CFLAGS@'
index 0f7a1dc787625f7086529dca2cd6db8a2646b9d3..635956b309fc1a1ace5cc0289b6b6ba79285d562 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -1498,22 +1498,19 @@ class PyBuildExt(build_ext):
                     return False
 
             fficonfig = {}
-            fp = open(ffi_configfile)
-            try:
-                script = fp.read()
-            finally:
-                fp.close()
-            exec(script, globals(), fficonfig)
-            ffi_srcdir = os.path.join(fficonfig['ffi_srcdir'], 'src')
+            with open(ffi_configfile) as f:
+                exec(f.read(), globals(), fficonfig)
 
             # Add .S (preprocessed assembly) to C compiler source extensions.
             self.compiler_obj.src_extensions.append('.S')
 
             include_dirs = [os.path.join(ffi_builddir, 'include'),
-                            ffi_builddir, ffi_srcdir]
+                            ffi_builddir,
+                            os.path.join(ffi_srcdir, 'src')]
             extra_compile_args = fficonfig['ffi_cflags'].split()
 
-            ext.sources.extend(fficonfig['ffi_sources'])
+            ext.sources.extend(os.path.join(ffi_srcdir, f) for f in
+                               fficonfig['ffi_sources'])
             ext.include_dirs.extend(include_dirs)
             ext.extra_compile_args.extend(extra_compile_args)
         return True