[pypy-svn] r71892 - in pypy/release/1.2.x: ctypes_configure ctypes_configure/test pypy/lib pypy/lib/app_test pypy/lib/ctypes_config_cache pypy/lib/ctypes_config_cache/test pypy/module/imp pypy/module/imp/test pypy/translator/goal pypy/translator/sandbox pypy/translator/sandbox/test

arigo at codespeak.net arigo at codespeak.net
Mon Mar 8 17:12:05 CET 2010


Author: arigo
Date: Mon Mar  8 17:12:03 2010
New Revision: 71892

Added:
   pypy/release/1.2.x/ctypes_configure/dumpcache.py
      - copied unchanged from r71873, pypy/trunk/ctypes_configure/dumpcache.py
   pypy/release/1.2.x/ctypes_configure/test/test_dumpcache.py
      - copied unchanged from r71873, pypy/trunk/ctypes_configure/test/test_dumpcache.py
   pypy/release/1.2.x/pypy/lib/app_test/test_syslog.py
      - copied unchanged from r71873, pypy/trunk/pypy/lib/app_test/test_syslog.py
   pypy/release/1.2.x/pypy/lib/ctypes_config_cache/   (props changed)
      - copied from r71873, pypy/trunk/pypy/lib/ctypes_config_cache/
Removed:
   pypy/release/1.2.x/pypy/lib/ctypes_configure
Modified:
   pypy/release/1.2.x/ctypes_configure/cbuild.py
   pypy/release/1.2.x/ctypes_configure/configure.py
   pypy/release/1.2.x/pypy/lib/_hashlib.py
   pypy/release/1.2.x/pypy/lib/_locale.py
   pypy/release/1.2.x/pypy/lib/app_test/test_hashlib.py
   pypy/release/1.2.x/pypy/lib/app_test/test_locale.py
   pypy/release/1.2.x/pypy/lib/app_test/test_pyexpat.py
   pypy/release/1.2.x/pypy/lib/app_test/test_resource.py
   pypy/release/1.2.x/pypy/lib/ctypes_config_cache/test/   (props changed)
   pypy/release/1.2.x/pypy/lib/pyexpat.py
   pypy/release/1.2.x/pypy/lib/resource.py
   pypy/release/1.2.x/pypy/lib/syslog.py
   pypy/release/1.2.x/pypy/module/imp/importing.py
   pypy/release/1.2.x/pypy/module/imp/test/test_import.py
   pypy/release/1.2.x/pypy/translator/goal/targetpypystandalone.py
   pypy/release/1.2.x/pypy/translator/sandbox/pypy_interact.py
   pypy/release/1.2.x/pypy/translator/sandbox/test/test_pypy_interact.py
   pypy/release/1.2.x/pypy/translator/sandbox/test/test_vfs.py
   pypy/release/1.2.x/pypy/translator/sandbox/vfs.py
Log:
svn merge svn+ssh://codespeak.net/svn/pypy/trunk -r71868:71873


Modified: pypy/release/1.2.x/ctypes_configure/cbuild.py
==============================================================================
--- pypy/release/1.2.x/ctypes_configure/cbuild.py	(original)
+++ pypy/release/1.2.x/ctypes_configure/cbuild.py	Mon Mar  8 17:12:03 2010
@@ -5,7 +5,7 @@
 
 debug = 0
 
-configdir = py.path.local.make_numbered_dir(prefix='ctypes_configure')
+configdir = py.path.local.make_numbered_dir(prefix='ctypes_configure-')
 
 class ExternalCompilationInfo(object):
 

Modified: pypy/release/1.2.x/ctypes_configure/configure.py
==============================================================================
--- pypy/release/1.2.x/ctypes_configure/configure.py	(original)
+++ pypy/release/1.2.x/ctypes_configure/configure.py	Mon Mar  8 17:12:03 2010
@@ -164,7 +164,7 @@
     for key in dir(CConfig):
         value = getattr(CConfig, key)
         if isinstance(value, CConfigEntry):
-            entries.append((key, value))            
+            entries.append((key, value))
 
     if entries:   # can be empty if there are only CConfigSingleEntries
         writer = _CWriter(CConfig)
@@ -201,7 +201,6 @@
             writer = _CWriter(CConfig)
             writer.write_header()
             res[key] = value.question(writer.ask_gcc)
-
     return res
 
 # ____________________________________________________________
@@ -210,7 +209,6 @@
 class CConfigEntry(object):
     "Abstract base class."
 
-
 class Struct(CConfigEntry):
     """An entry in a CConfig class that stands for an externally
     defined structure.
@@ -313,7 +311,6 @@
         S.__name__ = name
         return S
 
-
 class SimpleType(CConfigEntry):
     """An entry in a CConfig class that stands for an externally
     defined simple numeric type.
@@ -350,7 +347,6 @@
             ctype = fixup_ctype(ctype, self.name, (size, sign))
         return ctype
 
-
 class ConstantInteger(CConfigEntry):
     """An entry in a CConfig class that stands for an externally
     defined integer constant.

Modified: pypy/release/1.2.x/pypy/lib/_hashlib.py
==============================================================================
--- pypy/release/1.2.x/pypy/lib/_hashlib.py	(original)
+++ pypy/release/1.2.x/pypy/lib/_hashlib.py	Mon Mar  8 17:12:03 2010
@@ -1,6 +1,8 @@
 from ctypes import *
 import ctypes.util
-from ctypes_configure import configure
+
+# load the platform-specific cache made by running hashlib.ctc.py
+from ctypes_config_cache._hashlib_cache import *
 
 # Note: OpenSSL on OS X only provides md5 and sha1
 libpath = ctypes.util.find_library('ssl')
@@ -16,18 +18,6 @@
     else:
         return buffer(x)[:]
 
-class CConfig:
-    _compilation_info_ = configure.ExternalCompilationInfo(
-        includes=['openssl/evp.h'],
-        )
-    EVP_MD = configure.Struct('EVP_MD',
-                              [])
-    EVP_MD_CTX = configure.Struct('EVP_MD_CTX',
-                                  [('digest', c_void_p)])
-c = configure.configure(CConfig)
-EVP_MD_CTX = c['EVP_MD_CTX']
-EVP_MD = c['EVP_MD']
-
 def patch_fields(fields):
     res = []
     for k, v in fields:
@@ -39,7 +29,6 @@
 
 class EVP_MD_CTX(Structure):
     _fields_ = patch_fields(EVP_MD_CTX._fields_)
-del c
 
 # OpenSSL initialization
 lib.OpenSSL_add_all_digests()

Modified: pypy/release/1.2.x/pypy/lib/_locale.py
==============================================================================
--- pypy/release/1.2.x/pypy/lib/_locale.py	(original)
+++ pypy/release/1.2.x/pypy/lib/_locale.py	Mon Mar  8 17:12:03 2010
@@ -7,48 +7,16 @@
     c_ubyte, c_int, c_char_p, c_wchar_p)
 from ctypes_support import standard_c_lib as libc
 from ctypes_support import get_errno
-from ctypes_configure.configure import (configure, ExternalCompilationInfo,
-    ConstantInteger, DefinedConstantInteger, SimpleType)
+
+# load the platform-specific cache made by running locale.ctc.py
+from ctypes_config_cache._locale_cache import *
+
 
 size_t = c_int
 
 # XXX check where this comes from
 CHAR_MAX = 127
 
-_CONSTANTS = (
-    'LC_CTYPE',
-    'LC_NUMERIC',
-    'LC_TIME',
-    'LC_COLLATE',
-    'LC_MONETARY',
-    'LC_MESSAGES',
-    'LC_ALL',
-    'LC_PAPER',
-    'LC_NAME',
-    'LC_ADDRESS',
-    'LC_TELEPHONE',
-    'LC_MEASUREMENT',
-    'LC_IDENTIFICATION',
-)
-
-class LocaleConfigure:
-    _compilation_info_ = ExternalCompilationInfo(includes=['locale.h'])
-for key in _CONSTANTS:
-    setattr(LocaleConfigure, key, ConstantInteger(key))
-
-try:
-    locale_config = configure(LocaleConfigure, noerr=True)
-except Exception, e:
-    # should probably be moved into configure()
-    # as an optional feature
-    raise ImportError("%s: %s" % (e.__class__, e))
-
-for key in _CONSTANTS:
-    globals()[key] = locale_config[key]
-del LocaleConfigure
-del locale_config
-
-HAS_LANGINFO = True
 
 # Ubuntu Gusty i386 structure
 class lconv(Structure):
@@ -288,29 +256,6 @@
     raise NotImplementedError()
 
 if HAS_LANGINFO:
-    # this is incomplete list
-    langinfo_names = ('CODESET D_T_FMT D_FMT T_FMT RADIXCHAR THOUSEP '
-                      'YESEXPR NOEXPR CRNCYSTR').split(" ")
-    for i in range(1, 8):
-        langinfo_names.append("DAY_%d" % i)
-        langinfo_names.append("ABDAY_%d" % i)
-    for i in range(1, 13):
-        langinfo_names.append("MON_%d" % i)
-        langinfo_names.append("ABMON_%d" % i)
-    
-    class LanginfoConfigure:
-        _compilation_info_ = ExternalCompilationInfo(includes=['langinfo.h'])
-        nl_item = SimpleType('nl_item')
-    for key in langinfo_names:
-        setattr(LanginfoConfigure, key, ConstantInteger(key))
-
-    config = configure(LanginfoConfigure)
-    nl_item = config['nl_item']
-    for key in langinfo_names:
-        globals()[key] = config[key]
-    del LanginfoConfigure
-    del config
-
     _nl_langinfo = libc.nl_langinfo
     _nl_langinfo.argtypes = (nl_item,)
     _nl_langinfo.restype = c_char_p
@@ -369,9 +314,8 @@
     'setlocale', 'localeconv', 'strxfrm', 'strcoll',
     'gettext', 'dgettext', 'dcgettext', 'textdomain',
     'bindtextdomain', 'CHAR_MAX',
-) + _CONSTANTS + tuple(langinfo_names)
+) + ALL_CONSTANTS
 if _bind_textdomain_codeset:
     __all__ += ('bind_textdomain_codeset',)
 if HAS_LANGINFO:
     __all__ += ('nl_langinfo',)
-

Modified: pypy/release/1.2.x/pypy/lib/app_test/test_hashlib.py
==============================================================================
--- pypy/release/1.2.x/pypy/lib/app_test/test_hashlib.py	(original)
+++ pypy/release/1.2.x/pypy/lib/app_test/test_hashlib.py	Mon Mar  8 17:12:03 2010
@@ -1,3 +1,6 @@
+from pypy.lib.ctypes_config_cache import rebuild
+rebuild.rebuild_one('hashlib.ctc.py')
+
 from pypy.lib import hashlib, _hashlib
 
 def test_unicode():

Modified: pypy/release/1.2.x/pypy/lib/app_test/test_locale.py
==============================================================================
--- pypy/release/1.2.x/pypy/lib/app_test/test_locale.py	(original)
+++ pypy/release/1.2.x/pypy/lib/app_test/test_locale.py	Mon Mar  8 17:12:03 2010
@@ -1,14 +1,19 @@
 import py
-import locale
 import sys
 
+from pypy.lib.ctypes_config_cache import rebuild
+rebuild.rebuild_one('locale.ctc.py')
+
+from pypy.lib import _locale
+
+
 def setup_module(mod):
     if sys.platform == 'darwin':
         py.test.skip("Locale support on MacOSX is minimal and cannot be tested")
 
 class TestLocale:
     def setup_class(cls):
-        cls.oldlocale = locale.setlocale(locale.LC_NUMERIC)
+        cls.oldlocale = _locale.setlocale(_locale.LC_NUMERIC)
         if sys.platform.startswith("win"):
             cls.tloc = "en"
         elif sys.platform.startswith("freebsd"):
@@ -16,14 +21,15 @@
         else:
             cls.tloc = "en_US.UTF8"
         try:
-            locale.setlocale(locale.LC_NUMERIC, cls.tloc)
-        except locale.Error:
+            _locale.setlocale(_locale.LC_NUMERIC, cls.tloc)
+        except _locale.Error:
             py.test.skip("test locale %s not supported" % cls.tloc)
             
     def teardown_class(cls):
-        locale.setlocale(locale.LC_NUMERIC, cls.oldlocale)
+        _locale.setlocale(_locale.LC_NUMERIC, cls.oldlocale)
 
     def test_format(self):
+        py.test.skip("XXX fix or kill me")
 
         def testformat(formatstr, value, grouping = 0, output=None):
             if output:
@@ -41,8 +47,11 @@
         testformat("%20.f", -42, grouping=1, output='                 -42')
         testformat("%+10.f", -4200, grouping=1, output='    -4,200')
         testformat("%-10.f", 4200, grouping=1, output='4,200     ')
-        # Invoke getpreferredencoding to make sure it does not cause exceptions,
-        locale.getpreferredencoding()
+
+    def test_getpreferredencoding(self):
+        py.test.skip("XXX fix or kill me")
+        # Invoke getpreferredencoding to make sure it does not cause exceptions
+        _locale.getpreferredencoding()
 
     # Test BSD Rune locale's bug for isctype functions.
     def test_bsd_bug(self):
@@ -51,8 +60,8 @@
             result = getattr(s, method)()
             assert result == output
 
-        oldlocale = locale.setlocale(locale.LC_CTYPE)
-        locale.setlocale(locale.LC_CTYPE, self.tloc)
+        oldlocale = _locale.setlocale(_locale.LC_CTYPE)
+        _locale.setlocale(_locale.LC_CTYPE, self.tloc)
         try:
             teststrop('\x20', 'isspace', True)
             teststrop('\xa0', 'isspace', False)
@@ -66,4 +75,4 @@
             teststrop('\xcc\x85', 'lower', '\xcc\x85')
             teststrop('\xed\x95\xa0', 'upper', '\xed\x95\xa0')
         finally:
-            locale.setlocale(locale.LC_CTYPE, oldlocale)
+            _locale.setlocale(_locale.LC_CTYPE, oldlocale)

Modified: pypy/release/1.2.x/pypy/lib/app_test/test_pyexpat.py
==============================================================================
--- pypy/release/1.2.x/pypy/lib/app_test/test_pyexpat.py	(original)
+++ pypy/release/1.2.x/pypy/lib/app_test/test_pyexpat.py	Mon Mar  8 17:12:03 2010
@@ -4,6 +4,9 @@
 import StringIO, sys
 import unittest, py
 
+from pypy.lib.ctypes_config_cache import rebuild
+rebuild.rebuild_one('pyexpat.ctc.py')
+
 from pypy.lib import pyexpat
 #from xml.parsers import expat
 expat = pyexpat

Modified: pypy/release/1.2.x/pypy/lib/app_test/test_resource.py
==============================================================================
--- pypy/release/1.2.x/pypy/lib/app_test/test_resource.py	(original)
+++ pypy/release/1.2.x/pypy/lib/app_test/test_resource.py	Mon Mar  8 17:12:03 2010
@@ -1,3 +1,6 @@
+from pypy.lib.ctypes_config_cache import rebuild
+rebuild.rebuild_one('resource.ctc.py')
+
 from pypy.lib import resource
 
 def test_resource():

Modified: pypy/release/1.2.x/pypy/lib/pyexpat.py
==============================================================================
--- pypy/release/1.2.x/pypy/lib/pyexpat.py	(original)
+++ pypy/release/1.2.x/pypy/lib/pyexpat.py	Mon Mar  8 17:12:03 2010
@@ -1,46 +1,15 @@
 
 import ctypes
 import ctypes.util
-from ctypes_configure import configure
 from ctypes import c_char_p, c_int, c_void_p, POINTER, c_char, c_wchar_p
 import sys
 
+# load the platform-specific cache made by running pyexpat.ctc.py
+from ctypes_config_cache._pyexpat_cache import *
+
+
 lib = ctypes.CDLL(ctypes.util.find_library('expat'))
 
-class CConfigure:
-    _compilation_info_ = configure.ExternalCompilationInfo(
-        includes = ['expat.h'],
-        libraries = ['expat'],
-        pre_include_lines = [
-        '#define XML_COMBINED_VERSION (10000*XML_MAJOR_VERSION+100*XML_MINOR_VERSION+XML_MICRO_VERSION)'],
-        )
-
-    XML_Char = configure.SimpleType('XML_Char', ctypes.c_char)
-    XML_COMBINED_VERSION = configure.ConstantInteger('XML_COMBINED_VERSION')
-    for name in ['XML_PARAM_ENTITY_PARSING_NEVER',
-                 'XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE',
-                 'XML_PARAM_ENTITY_PARSING_ALWAYS']:
-        locals()[name] = configure.ConstantInteger(name)
-
-    XML_Encoding = configure.Struct('XML_Encoding',[
-                                    ('data', c_void_p),
-                                    ('convert', c_void_p),
-                                    ('release', c_void_p),
-                                    ('map', c_int * 256)])
-    XML_Content = configure.Struct('XML_Content',[
-        ('numchildren', c_int),
-        ('children', c_void_p),
-        ('name', c_char_p),
-        ('type', c_int),
-        ('quant', c_int),
-    ])
-    # this is insanely stupid
-    XML_FALSE = configure.ConstantInteger('XML_FALSE')
-    XML_TRUE = configure.ConstantInteger('XML_TRUE')
-
-info = configure.configure(CConfigure)
-for k, v in info.items():
-    globals()[k] = v
 
 XML_Content.children = POINTER(XML_Content)
 XML_Parser = ctypes.c_void_p # an opaque pointer

Modified: pypy/release/1.2.x/pypy/lib/resource.py
==============================================================================
--- pypy/release/1.2.x/pypy/lib/resource.py	(original)
+++ pypy/release/1.2.x/pypy/lib/resource.py	Mon Mar  8 17:12:03 2010
@@ -2,45 +2,18 @@
 if sys.platform == 'win32':
     raise ImportError('resource module not available for win32')
 
+# load the platform-specific cache made by running resource.ctc.py
+from ctypes_config_cache._resource_cache import *
+
 from ctypes_support import standard_c_lib as libc
 from ctypes_support import get_errno
 from ctypes import Structure, c_int, c_long, byref, sizeof
 from errno import EINVAL, EPERM
-from ctypes_configure.configure import (configure,
-    ExternalCompilationInfo, ConstantInteger, DefinedConstantInteger,
-    SimpleType)
 import _structseq
 
 class error(Exception):
     pass
 
-_CONSTANTS = (
-    'RLIM_INFINITY',
-    'RLIM_NLIMITS',
-)
-_OPTIONAL_CONSTANTS = (
-    'RLIMIT_CPU',
-    'RLIMIT_FSIZE',
-    'RLIMIT_DATA',
-    'RLIMIT_STACK',
-    'RLIMIT_CORE',
-    'RLIMIT_RSS',
-    'RLIMIT_NPROC',
-    'RLIMIT_NOFILE',
-    'RLIMIT_OFILE',
-    'RLIMIT_MEMLOCK',
-    'RLIMIT_AS',
-    'RLIMIT_LOCKS',
-    'RLIMIT_SIGPENDING',
-    'RLIMIT_MSGQUEUE',
-    'RLIMIT_NICE',
-    'RLIMIT_RTPRIO',
-    'RLIMIT_VMEM',
-
-    'RUSAGE_BOTH',
-    'RUSAGE_SELF',
-    'RUSAGE_CHILDREN',
-)
 
 # Read required libc functions
 _getrusage = libc.getrusage
@@ -52,27 +25,6 @@
     from os import sysconf
     _getpagesize = None
 
-# Setup our configure
-class ResourceConfigure:
-    _compilation_info_ = ExternalCompilationInfo(includes=['sys/resource.h'])
-    rlim_t = SimpleType('rlim_t')
-for key in _CONSTANTS:
-    setattr(ResourceConfigure, key, ConstantInteger(key))
-for key in _OPTIONAL_CONSTANTS:
-    setattr(ResourceConfigure, key, DefinedConstantInteger(key))
-
-# Configure constants and types
-config = configure(ResourceConfigure)
-rlim_t = config['rlim_t']
-sizeof_rlim_t = 1<<(sizeof(rlim_t) * 8)
-for key in _CONSTANTS:
-    globals()[key] = config[key]
-optional_constants = []
-for key in _OPTIONAL_CONSTANTS:
-    if config[key] is not None:
-        globals()[key] = config[key]
-        optional_constants.append(key)
-del config
 
 class timeval(Structure):
     _fields_ = (
@@ -126,9 +78,9 @@
     ru_nivcsw = _structseq.structseqfield(15)
 
 def rlimit_check_bounds(rlim_cur, rlim_max):
-    if rlim_cur > sizeof_rlim_t:
+    if rlim_cur > rlim_t_max:
         raise ValueError("%d does not fit into rlim_t" % rlim_cur)
-    if rlim_max > sizeof_rlim_t:
+    if rlim_max > rlim_t_max:
         raise ValueError("%d does not fit into rlim_t" % rlim_max)
 
 class rlimit(Structure):
@@ -202,10 +154,9 @@
             # Irix 5.3 has _SC_PAGESIZE, but not _SC_PAGE_SIZE
             return sysconf("SC_PAGESIZE")
 
-__all__ = _CONSTANTS + tuple(optional_constants) + (
+__all__ = ALL_CONSTANTS + (
     'error', 'timeval', 'struct_rusage', 'rlimit',
     'getrusage', 'getrlimit', 'setrlimit', 'getpagesize',
 )
 
-del optional_constants
-
+del ALL_CONSTANTS

Modified: pypy/release/1.2.x/pypy/lib/syslog.py
==============================================================================
--- pypy/release/1.2.x/pypy/lib/syslog.py	(original)
+++ pypy/release/1.2.x/pypy/lib/syslog.py	Mon Mar  8 17:12:03 2010
@@ -9,79 +9,11 @@
 if sys.platform == 'win32':
     raise ImportError("No syslog on Windows")
 
+# load the platform-specific cache made by running syslog.ctc.py
+from ctypes_config_cache._syslog_cache import *
+
 from ctypes_support import standard_c_lib as libc
 from ctypes import c_int, c_char_p
-from ctypes_configure.configure import (configure,
-    ExternalCompilationInfo, ConstantInteger, DefinedConstantInteger)
-
-_CONSTANTS = (
-    'LOG_EMERG',
-    'LOG_ALERT',
-    'LOG_CRIT',
-    'LOG_ERR',
-    'LOG_WARNING',
-    'LOG_NOTICE',
-    'LOG_INFO',
-    'LOG_DEBUG',
-
-    'LOG_PID',
-    'LOG_CONS',
-    'LOG_NDELAY',
-
-    'LOG_KERN',
-    'LOG_USER',
-    'LOG_MAIL',
-    'LOG_DAEMON',
-    'LOG_AUTH',
-    'LOG_LPR',
-    'LOG_LOCAL0',
-    'LOG_LOCAL1',
-    'LOG_LOCAL2',
-    'LOG_LOCAL3',
-    'LOG_LOCAL4',
-    'LOG_LOCAL5',
-    'LOG_LOCAL6',
-    'LOG_LOCAL7',
-)
-_OPTIONAL_CONSTANTS = (
-    'LOG_NOWAIT',
-    'LOG_PERROR',
-
-    'LOG_SYSLOG',
-    'LOG_CRON',
-    'LOG_UUCP',
-    'LOG_NEWS',
-)
-
-# Constant aliases if there are not defined
-_ALIAS = (
-    ('LOG_SYSLOG', 'LOG_DAEMON'),
-    ('LOG_CRON', 'LOG_DAEMON'),
-    ('LOG_NEWS', 'LOG_MAIL'),
-    ('LOG_UUCP', 'LOG_MAIL'),
-)
-
-class SyslogConfigure:
-    _compilation_info_ = ExternalCompilationInfo(includes=['sys/syslog.h'])
-for key in _CONSTANTS:
-    setattr(SyslogConfigure, key, ConstantInteger(key))
-for key in _OPTIONAL_CONSTANTS:
-    setattr(SyslogConfigure, key, DefinedConstantInteger(key))
-
-config = configure(SyslogConfigure)
-for key in _CONSTANTS:
-    globals()[key] = config[key]
-optional_constants = []
-for key in _OPTIONAL_CONSTANTS:
-    if config[key] is not None:
-        globals()[key] = config[key]
-        optional_constants.append(key)
-for alias, key in _ALIAS:
-    if alias in optional_constants:
-        continue
-    globals()[alias] = globals()[key]
-    optional_constants.append(alias)
-del config
 
 # Real prototype is:
 # void syslog(int priority, const char *format, ...);
@@ -124,9 +56,8 @@
 def LOG_UPTO(pri):
     return (1 << (pri + 1)) - 1
 
-__all__ = _CONSTANTS + tuple(optional_constants) + (
+__all__ = ALL_CONSTANTS + (
     'openlog', 'syslog', 'closelog', 'setlogmask',
     'LOG_MASK', 'LOG_UPTO')
 
-del optional_constants
-
+del ALL_CONSTANTS

Modified: pypy/release/1.2.x/pypy/module/imp/importing.py
==============================================================================
--- pypy/release/1.2.x/pypy/module/imp/importing.py	(original)
+++ pypy/release/1.2.x/pypy/module/imp/importing.py	Mon Mar  8 17:12:03 2010
@@ -648,9 +648,9 @@
     d = x & 0xff
     stream.write(chr(a) + chr(b) + chr(c) + chr(d))
 
-def check_compiled_module(space, pycfilename, expected_mtime=0):
+def check_compiled_module(space, pycfilename, expected_mtime):
     """
-    Check if a pyc file's magic number and (optionally) mtime match.
+    Check if a pyc file's magic number and mtime match.
     """
     stream = None
     try:
@@ -659,11 +659,10 @@
         if magic != get_pyc_magic(space):
             stream.close()
             return None
-        if expected_mtime != 0:
-            pyc_mtime = _r_long(stream)
-            if pyc_mtime != expected_mtime:
-                stream.close()
-                return None
+        pyc_mtime = _r_long(stream)
+        if pyc_mtime != expected_mtime:
+            stream.close()
+            return None
         return stream
     except StreamErrors:
         if stream:

Modified: pypy/release/1.2.x/pypy/module/imp/test/test_import.py
==============================================================================
--- pypy/release/1.2.x/pypy/module/imp/test/test_import.py	(original)
+++ pypy/release/1.2.x/pypy/module/imp/test/test_import.py	Mon Mar  8 17:12:03 2010
@@ -496,6 +496,12 @@
                                               cpathname,
                                               mtime+1)
         assert ret is None
+
+        # also check with expected mtime==0 (nothing special any more about 0)
+        ret = importing.check_compiled_module(space,
+                                              cpathname,
+                                              0)
+        assert ret is None
         os.remove(cpathname)
 
         # check for wrong version

Modified: pypy/release/1.2.x/pypy/translator/goal/targetpypystandalone.py
==============================================================================
--- pypy/release/1.2.x/pypy/translator/goal/targetpypystandalone.py	(original)
+++ pypy/release/1.2.x/pypy/translator/goal/targetpypystandalone.py	Mon Mar  8 17:12:03 2010
@@ -186,6 +186,10 @@
         #elif config.objspace.usemodules.clr:
         #    config.translation.backend == "cli"
 
+        if config.translation.sandbox:
+            config.objspace.lonepycfiles = False
+            config.objspace.usepycfiles = False
+
         config.objspace.nofaking = True
         config.objspace.compiler = "ast"
         config.translating = True
@@ -216,6 +220,9 @@
         return PyPyJitPolicy()
     
     def get_entry_point(self, config):
+        from pypy.lib.ctypes_config_cache import rebuild
+        rebuild.try_rebuild()
+
         space = make_objspace(config)
 
         # manually imports app_main.py

Modified: pypy/release/1.2.x/pypy/translator/sandbox/pypy_interact.py
==============================================================================
--- pypy/release/1.2.x/pypy/translator/sandbox/pypy_interact.py	(original)
+++ pypy/release/1.2.x/pypy/translator/sandbox/pypy_interact.py	Mon Mar  8 17:12:03 2010
@@ -45,18 +45,21 @@
         # * can access its own executable
         # * can access the pure Python libraries
         # * can access the temporary usession directory as /tmp
+        exclude = ['.pyc', '.pyo']
         if self.tmpdir is None:
             tmpdirnode = Dir({})
         else:
-            tmpdirnode = RealDir(self.tmpdir)
+            tmpdirnode = RealDir(self.tmpdir, exclude=exclude)
         pypydist = os.path.dirname(os.path.abspath(autopath.pypydir))
 
         return Dir({
             'bin': Dir({
                 'pypy-c': RealFile(self.executable),
-                'lib-python': RealDir(os.path.join(pypydist, 'lib-python')),
+                'lib-python': RealDir(os.path.join(pypydist, 'lib-python'),
+                                      exclude=exclude),
                 'pypy': Dir({
-                    'lib': RealDir(os.path.join(pypydist, 'pypy', 'lib')),
+                    'lib': RealDir(os.path.join(pypydist, 'pypy', 'lib'),
+                                   exclude=exclude),
                     }),
                 }),
              'tmp': tmpdirnode,

Modified: pypy/release/1.2.x/pypy/translator/sandbox/test/test_pypy_interact.py
==============================================================================
--- pypy/release/1.2.x/pypy/translator/sandbox/test/test_pypy_interact.py	(original)
+++ pypy/release/1.2.x/pypy/translator/sandbox/test/test_pypy_interact.py	Mon Mar  8 17:12:03 2010
@@ -36,6 +36,12 @@
         assert_(False, "os.stat('site') should have failed")
     st = os.stat('/bin/lib-python/modified-2.5.2/site.py')
     assert_(stat.S_ISREG(st.st_mode), "bad st_mode for .../site.py")
+    try:
+        os.stat('/bin/lib-python/modified-2.5.2/site.pyc')
+    except OSError:
+        pass
+    else:
+        assert_(False, "os.stat('....pyc') should have failed")
     fd = os.open('/bin/lib-python/modified-2.5.2/site.py', os.O_RDONLY, 0666)
     length = 8192
     ofs = 0

Modified: pypy/release/1.2.x/pypy/translator/sandbox/test/test_vfs.py
==============================================================================
--- pypy/release/1.2.x/pypy/translator/sandbox/test/test_vfs.py	(original)
+++ pypy/release/1.2.x/pypy/translator/sandbox/test/test_vfs.py	Mon Mar  8 17:12:03 2010
@@ -90,3 +90,19 @@
             else:
                 py.test.raises(OSError, v_test_vfs.join, '.hidden')
                 py.test.raises(OSError, v_test_vfs.join, '.subdir2')
+
+def test_realdir_exclude():
+    xdir = udir.ensure('test_realdir_exclude', dir=1)
+    xdir.ensure('test_realdir_exclude.yes')
+    xdir.ensure('test_realdir_exclude.no')
+    v_udir = RealDir(str(udir), exclude=['.no'])
+    v_xdir = v_udir.join('test_realdir_exclude')
+    assert 'test_realdir_exclude.yes' in v_xdir.keys()
+    assert 'test_realdir_exclude.no' not in v_xdir.keys()
+    v_xdir.join('test_realdir_exclude.yes')    # works
+    py.test.raises(OSError, v_xdir.join, 'test_realdir_exclude.no')
+    # Windows and Mac tests, for the case
+    py.test.raises(OSError, v_xdir.join, 'Test_RealDir_Exclude.no')
+    py.test.raises(OSError, v_xdir.join, 'test_realdir_exclude.No')
+    py.test.raises(OSError, v_xdir.join, 'test_realdir_exclude.nO')
+    py.test.raises(OSError, v_xdir.join, 'test_realdir_exclude.NO')

Modified: pypy/release/1.2.x/pypy/translator/sandbox/vfs.py
==============================================================================
--- pypy/release/1.2.x/pypy/translator/sandbox/vfs.py	(original)
+++ pypy/release/1.2.x/pypy/translator/sandbox/vfs.py	Mon Mar  8 17:12:03 2010
@@ -64,21 +64,30 @@
     # with '.' simply don't exist.  If follow_links=True, then symlinks are
     # transparently followed (they look like a regular file or directory to
     # the sandboxed process).  If follow_links=False, the subprocess is
-    # not allowed to access them at all.
-    def __init__(self, path, show_dotfiles=False, follow_links=False):
+    # not allowed to access them at all.  Finally, exclude is a list of
+    # file endings that we filter out (note that we also filter out files
+    # with the same ending but a different case, to be safe).
+    def __init__(self, path, show_dotfiles=False, follow_links=False,
+                 exclude=[]):
         self.path = path
         self.show_dotfiles = show_dotfiles
         self.follow_links  = follow_links
+        self.exclude       = [excl.lower() for excl in exclude]
     def __repr__(self):
         return '<RealDir %s>' % (self.path,)
     def keys(self):
         names = os.listdir(self.path)
         if not self.show_dotfiles:
             names = [name for name in names if not name.startswith('.')]
+        for excl in self.exclude:
+            names = [name for name in names if not name.lower().endswith(excl)]
         return names
     def join(self, name):
         if name.startswith('.') and not self.show_dotfiles:
             raise OSError(errno.ENOENT, name)
+        for excl in self.exclude:
+            if name.lower().endswith(excl):
+                raise OSError(errno.ENOENT, name)
         path = os.path.join(self.path, name)
         if self.follow_links:
             st = os.stat(path)
@@ -86,7 +95,8 @@
             st = os.lstat(path)
         if stat.S_ISDIR(st.st_mode):
             return RealDir(path, show_dotfiles = self.show_dotfiles,
-                                 follow_links  = self.follow_links)
+                                 follow_links  = self.follow_links,
+                                 exclude       = self.exclude)
         elif stat.S_ISREG(st.st_mode):
             return RealFile(path)
         else:



More information about the Pypy-commit mailing list