Author: mattip <[email protected]>
Branch: disable_pythonapi
Changeset: r72177:6476e0537293
Date: 2014-06-23 22:04 +0300
http://bitbucket.org/pypy/pypy/changeset/6476e0537293/

Log:    remove dllhandle from sys module on windows, test and document

diff --git a/pypy/doc/cpython_differences.rst b/pypy/doc/cpython_differences.rst
--- a/pypy/doc/cpython_differences.rst
+++ b/pypy/doc/cpython_differences.rst
@@ -65,7 +65,7 @@
     signal
     struct
     symbol
-    sys
+    sys (without sys.dllhandle on windows)
     termios
     thread
     time
diff --git a/pypy/doc/ctypes-implementation.rst 
b/pypy/doc/ctypes-implementation.rst
--- a/pypy/doc/ctypes-implementation.rst
+++ b/pypy/doc/ctypes-implementation.rst
@@ -73,10 +73,7 @@
 current implementation:
 
 * ``ctypes.pythonapi`` lets you access the CPython C API 
-  emulation layer. It does not work on PyPy at the moment, we are missing a
-  ``getfunc`` method for CDLL. Work was begun
-  to refactor the rpython implementation of _rawffi (in 
-  pypy/modules/_rawffi/alt) but that project has stalled. 
+  emulation layer. It does not work on PyPy.
 
   Note that even if it worked, our implementation would not do anything 
   sensible about the GIL and the functions will be named with an extra
diff --git a/pypy/module/sys/__init__.py b/pypy/module/sys/__init__.py
--- a/pypy/module/sys/__init__.py
+++ b/pypy/module/sys/__init__.py
@@ -108,12 +108,6 @@
             # don't get the filesystemencoding at translation time
             assert self.filesystemencoding is None
 
-        else:
-            if _WIN:
-                from pypy.module.sys import vm
-                w_handle = vm.get_dllhandle(space)
-                space.setitem(self.w_dict, space.wrap("dllhandle"), w_handle)
-
     def getmodule(self, name):
         space = self.space
         w_modules = self.get('modules')
diff --git a/pypy/module/sys/test/test_sysmodule.py 
b/pypy/module/sys/test/test_sysmodule.py
--- a/pypy/module/sys/test/test_sysmodule.py
+++ b/pypy/module/sys/test/test_sysmodule.py
@@ -391,7 +391,8 @@
         import sys
         if hasattr(sys, "getwindowsversion"):
             v = sys.getwindowsversion()
-            assert isinstance(v, tuple)
+            if '__pypy__' in sys.builtin_module_names:
+                assert isinstance(v, tuple)
             assert len(v) == 5
             assert isinstance(v[0], int)
             assert isinstance(v[1], int)
@@ -419,6 +420,14 @@
         if hasattr(sys, "winver"):
             assert sys.winver == sys.version[:3]
 
+    def test_no_dllhandle(self):
+        import sys
+        if '__pypy__' in sys.builtin_module_names:
+            assert not hasattr(sys, 'dllhandle')
+        elif sys.platform == 'win32':
+            # only on cpython win32
+            assert hasattr(sys, 'dllhandle')
+
     def test_dlopenflags(self):
         import sys
         if hasattr(sys, "setdlopenflags"):
@@ -486,7 +495,8 @@
         assert isinstance(sys.version, basestring)
         assert isinstance(sys.warnoptions, list)
         vi = sys.version_info
-        assert isinstance(vi, tuple)
+        if '__pypy__' in sys.builtin_module_names:
+            assert isinstance(vi, tuple)
         assert len(vi) == 5
         assert isinstance(vi[0], int)
         assert isinstance(vi[1], int)
@@ -512,6 +522,8 @@
 
     def test_pypy_attributes(self):
         import sys
+        if '__pypy__' not in sys.builtin_module_names:
+            skip("only on PyPy")
         assert isinstance(sys.pypy_objspaceclass, str)
         vi = sys.pypy_version_info
         assert isinstance(vi, tuple)
@@ -528,10 +540,14 @@
 
     def test_subversion(self):
         import sys
+        if '__pypy__' not in sys.builtin_module_names:
+            skip("only on PyPy")
         assert sys.subversion == ('PyPy', '', '')
 
     def test__mercurial(self):
         import sys, re
+        if '__pypy__' not in sys.builtin_module_names:
+            skip("only on PyPy")
         project, hgtag, hgid = sys._mercurial
         assert project == 'PyPy'
         # the tag or branch may be anything, including the empty string
diff --git a/pypy/module/sys/vm.py b/pypy/module/sys/vm.py
--- a/pypy/module/sys/vm.py
+++ b/pypy/module/sys/vm.py
@@ -229,26 +229,6 @@
     ])
     return space.call_function(w_windows_version_info, raw_version)
 
[email protected]_look_inside
-def get_dllhandle(space):
-    if not space.config.objspace.usemodules.cpyext:
-        return space.wrap(0)
-    if not space.config.objspace.usemodules._rawffi:
-        return space.wrap(0)
-
-    return _get_dllhandle(space)
-
-def _get_dllhandle(space):
-    # Retrieve cpyext api handle
-    from pypy.module.cpyext.api import State
-    handle = space.fromcache(State).get_pythonapi_handle()
-
-    # Make a dll object with it
-    from pypy.module._rawffi.interp_rawffi import W_CDLL
-    from rpython.rlib.clibffi import RawCDLL
-    cdll = RawCDLL(handle)
-    return space.wrap(W_CDLL(space, "python api", cdll))
-
 def getsizeof(space, w_object, w_default=None):
     """Not implemented on PyPy."""
     if w_default is None:
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to