diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py index 0c8e5976411..6134c93c965 100644 --- a/Lib/test/test_os.py +++ b/Lib/test/test_os.py @@ -10,6 +10,17 @@ import shutil from test import support +# Detect whether we're on a Linux system that uses the (now outdated +# and unmaintained) linuxthreads threading library. There's an issue +# when combining linuxthreads with a failed execv call: see +# http://bugs.python.org/issue4970. +if (hasattr(os, "confstr_names") and + "CS_GNU_LIBPTHREAD_VERSION" in os.confstr_names): + libpthread = os.confstr("CS_GNU_LIBPTHREAD_VERSION") + USING_LINUXTHREADS= libpthread.startswith("linuxthreads") +else: + USING_LINUXTHREADS= False + # Tests creating TESTFN class FileTests(unittest.TestCase): def setUp(self): @@ -566,8 +577,11 @@ def test_urandom(self): pass class ExecTests(unittest.TestCase): + @unittest.skipIf(USING_LINUXTHREADS, + "avoid triggering a linuxthreads bug: see issue #4970") def test_execvpe_with_bad_program(self): - self.assertRaises(OSError, os.execvpe, 'no such app-', ['no such app-'], None) + self.assertRaises(OSError, os.execvpe, 'no such app-', + ['no such app-'], None) def test_execvpe_with_bad_arglist(self): self.assertRaises(ValueError, os.execvpe, 'notepad', [], None) diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index bba75aff486..c7e073641c7 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -6028,6 +6028,12 @@ static struct constdef posix_constants_confstr[] = { #ifdef _CS_ARCHITECTURE {"CS_ARCHITECTURE", _CS_ARCHITECTURE}, #endif +#ifdef _CS_GNU_LIBC_VERSION + {"CS_GNU_LIBC_VERSION", _CS_GNU_LIBC_VERSION}, +#endif +#ifdef _CS_GNU_LIBPTHREAD_VERSION + {"CS_GNU_LIBPTHREAD_VERSION", _CS_GNU_LIBPTHREAD_VERSION}, +#endif #ifdef _CS_HOSTNAME {"CS_HOSTNAME", _CS_HOSTNAME}, #endif