]> granicus.if.org Git - python/commitdiff
Issue #13226: Add RTLD_xxx constants to the os module. These constants can by
authorVictor Stinner <victor.stinner@haypocalc.com>
Tue, 25 Oct 2011 11:34:04 +0000 (13:34 +0200)
committerVictor Stinner <victor.stinner@haypocalc.com>
Tue, 25 Oct 2011 11:34:04 +0000 (13:34 +0200)
used with sys.setdlopenflags().

Doc/library/os.rst
Doc/library/sys.rst
Lib/test/test_posix.py
Misc/NEWS
Modules/posixmodule.c

index b2a16d9e529e29c80978de80852bf8b8ca3cd1d2..fb794d33b7116b5f389fc1cdeffec1e68e35961e 100644 (file)
@@ -1393,6 +1393,19 @@ or `the MSDN <http://msdn.microsoft.com/en-us/library/z0kc8e3z.aspx>`_ on Window
    the C library.
 
 
+.. data:: RTLD_LAZY
+          RTLD_NOW
+          RTLD_GLOBAL
+          RTLD_LOCAL
+          RTLD_NODELETE
+          RTLD_NOLOAD
+          RTLD_DEEPBIND
+
+   See the Unix manual page :manpage:`dlopen(3)`.
+
+   .. versionadded:: 3.3
+
+
 .. _os-file-dir:
 
 Files and Directories
index 0a8ac8be1ab5e98d78a9639afcd75795c0a51bff..a0325493c87ed2cc03440d326d2a909ae52ea38a 100644 (file)
@@ -801,11 +801,11 @@ always available.
    the interpreter loads extension modules.  Among other things, this will enable a
    lazy resolving of symbols when importing a module, if called as
    ``sys.setdlopenflags(0)``.  To share symbols across extension modules, call as
-   ``sys.setdlopenflags(ctypes.RTLD_GLOBAL)``.  Symbolic names for the
-   flag modules can be either found in the :mod:`ctypes` module, or in the :mod:`DLFCN`
-   module. If :mod:`DLFCN` is not available, it can be generated from
-   :file:`/usr/include/dlfcn.h` using the :program:`h2py` script. Availability:
-   Unix.
+   ``sys.setdlopenflags(os.RTLD_GLOBAL)``.  Symbolic names for the flag modules
+   can be found in the :mod:`os` module (``RTLD_xxx`` constants, e.g.
+   :data:`os.RTLD_LAZY`).
+
+   Availability: Unix.
 
 .. function:: setprofile(profilefunc)
 
index f70688d8b5803db48cc46824e94c85d8ddc7bcc7..c8d0859e818e46f62efa76f9dadab0d4dde29448 100644 (file)
@@ -984,6 +984,13 @@ class PosixTester(unittest.TestCase):
         self.assertIs(b, l)
         self.assertEqual(l.count(), 3)
 
+    def test_rtld_constants(self):
+        # check presence of major RTLD_* constants
+        posix.RTLD_LAZY
+        posix.RTLD_NOW
+        posix.RTLD_GLOBAL
+        posix.RTLD_LOCAL
+
 class PosixGroupsTester(unittest.TestCase):
 
     def setUp(self):
index 0a8a3a8f3d00c0cb7a084dd02846b920a0db624c..eb73271537fdef1d375e99696074ca2ab6acb81d 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -341,6 +341,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #13226: Add RTLD_xxx constants to the os module. These constants can by
+  used with sys.setdlopenflags().
+
 - Issue #10278: Add clock_getres(), clock_gettime() and CLOCK_xxx constants to
   the time module. time.clock_gettime(time.CLOCK_MONOTONIC) provides a
   monotonic clock
index fa5029619e9323d44afb425fda045686d711525f..f4476b7d5eff43bf728157b73748b73c5ac44cb4 100644 (file)
@@ -121,6 +121,10 @@ corresponding Unix manual entries for more information on calls.");
 #endif
 #endif
 
+#ifdef HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
+
 /* Various compilers have only certain posix functions */
 /* XXX Gosh I wish these were all moved into pyconfig.h */
 #if defined(PYCC_VACPP) && defined(PYOS_OS2)
@@ -11423,6 +11427,28 @@ all_ins(PyObject *d)
     if (ins(d, "XATTR_SIZE_MAX", (long)XATTR_SIZE_MAX)) return -1;
 #endif
 
+#ifdef RTLD_LAZY
+    if (PyModule_AddIntMacro(d, RTLD_LAZY)) return -1;
+#endif
+#ifdef RTLD_NOW
+    if (PyModule_AddIntMacro(d, RTLD_NOW)) return -1;
+#endif
+#ifdef RTLD_GLOBAL
+    if (PyModule_AddIntMacro(d, RTLD_GLOBAL)) return -1;
+#endif
+#ifdef RTLD_LOCAL
+    if (PyModule_AddIntMacro(d, RTLD_LOCAL)) return -1;
+#endif
+#ifdef RTLD_NODELETE
+    if (PyModule_AddIntMacro(d, RTLD_NODELETE)) return -1;
+#endif
+#ifdef RTLD_NOLOAD
+    if (PyModule_AddIntMacro(d, RTLD_NOLOAD)) return -1;
+#endif
+#ifdef RTLD_DEEPBIND
+    if (PyModule_AddIntMacro(d, RTLD_DEEPBIND)) return -1;
+#endif
+
 #if defined(PYOS_OS2)
     if (insertvalues(d)) return -1;
 #endif