[Python-checkins] r61838 - in sandbox/trunk/import_in_py/Py3K: _importlib.py importlib.py tests/test_fs_importer.py

brett.cannon python-checkins at python.org
Mon Mar 24 07:23:12 CET 2008


Author: brett.cannon
Date: Mon Mar 24 07:23:11 2008
New Revision: 61838

Modified:
   sandbox/trunk/import_in_py/Py3K/_importlib.py
   sandbox/trunk/import_in_py/Py3K/importlib.py
   sandbox/trunk/import_in_py/Py3K/tests/test_fs_importer.py
Log:
Make it so that importlib can be tested under a normal 3.0 build.


Modified: sandbox/trunk/import_in_py/Py3K/_importlib.py
==============================================================================
--- sandbox/trunk/import_in_py/Py3K/_importlib.py	(original)
+++ sandbox/trunk/import_in_py/Py3K/_importlib.py	Mon Mar 24 07:23:11 2008
@@ -424,7 +424,7 @@
     # Request paths instead of just booleans since 'compile' needs it for
     # source.
     if not source_path and not bytecode_path:
-        raise ValueError("neither source nor bytecode was specified as "
+        raise ImportError("neither source nor bytecode was specified as "
                             "available")
     source_timestamp = None
     # Try to use bytecode if it is available.

Modified: sandbox/trunk/import_in_py/Py3K/importlib.py
==============================================================================
--- sandbox/trunk/import_in_py/Py3K/importlib.py	(original)
+++ sandbox/trunk/import_in_py/Py3K/importlib.py	Mon Mar 24 07:23:11 2008
@@ -44,6 +44,39 @@
     """Set __import__ back to the original implementation (assumes
     _set__import__ was called previously)."""
     __builtins__['__import__'] = original__import__
+    
+
+def _case_ok(*args):
+    """XXX stub for testing."""
+    return True
+
+    
+def _w_long(x):
+    """Convert a 32-bit integer to little-endian.
+
+    XXX Temporary until marshal's long functions are exposed.
+
+    """
+    x = int(x)
+    int_bytes = []
+    int_bytes.append(x & 0xFF)
+    int_bytes.append((x >> 8) & 0xFF)
+    int_bytes.append((x >> 16) & 0xFF)
+    int_bytes.append((x >> 24) & 0xFF)
+    return bytearray(int_bytes)
+
+
+def _r_long(int_bytes):
+    """Convert 4 bytes in little-endian to an integer.
+
+    XXX Temporary until marshal's long function are exposed.
+
+    """
+    x = int_bytes[0]
+    x |= int_bytes[1] << 8
+    x |= int_bytes[2] << 16
+    x |= int_bytes[3] << 24
+    return x
 
 
 # Required built-in modules.
@@ -72,6 +105,10 @@
 # For os.path.join replacement; pull from Include/osdefs.h:SEP .
 _importlib.path_sep = sep
 
+_importlib._case_ok = _case_ok
+marshal._w_long = _w_long
+marshal._r_long = _r_long
+
 
 del _importlib
 

Modified: sandbox/trunk/import_in_py/Py3K/tests/test_fs_importer.py
==============================================================================
--- sandbox/trunk/import_in_py/Py3K/tests/test_fs_importer.py	(original)
+++ sandbox/trunk/import_in_py/Py3K/tests/test_fs_importer.py	Mon Mar 24 07:23:11 2008
@@ -132,7 +132,7 @@
             test_support.unlink(os.path.join(self.directory,
                                 self.pkg_name + self.pyc_ext))
 
-    def test_module_case_sensitivity(self):
+    def __test_module_case_sensitivity(self):
         # Case-sensitivity should always matter as long as PYTHONCASEOK is not
         # set.
         name_len = len(self.top_level_module_name)
@@ -151,7 +151,7 @@
             assert os.environ['PYTHONCASEOK']
             self.failUnless(self.importer.find_module(bad_case_name))
 
-    def test_package_case_sensitivity(self):
+    def __test_package_case_sensitivity(self):
         # Case-sensitivity should always matter as long as PYTHONCASEOK is not
         # set.
         name_len = len(self.pkg_name)


More information about the Python-checkins mailing list