summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Lib/test/test_posix.py64
-rw-r--r--Misc/NEWS2
-rw-r--r--Modules/posixmodule.c8
-rw-r--r--Python/getcwd.c83
-rwxr-xr-xconfigure13
-rw-r--r--configure.ac2
-rw-r--r--pyconfig.h.in3
7 files changed, 34 insertions, 141 deletions
diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py
index 4856083dc8..3fd8f115cb 100644
--- a/Lib/test/test_posix.py
+++ b/Lib/test/test_posix.py
@@ -664,41 +664,39 @@ class PosixTester(unittest.TestCase):
self.assertEqual(type(v), item_type)
def test_getcwd_long_pathnames(self):
- if hasattr(posix, 'getcwd'):
- dirname = 'getcwd-test-directory-0123456789abcdef-01234567890abcdef'
- curdir = os.getcwd()
- base_path = os.path.abspath(support.TESTFN) + '.getcwd'
+ dirname = 'getcwd-test-directory-0123456789abcdef-01234567890abcdef'
+ curdir = os.getcwd()
+ base_path = os.path.abspath(support.TESTFN) + '.getcwd'
- try:
- os.mkdir(base_path)
- os.chdir(base_path)
- except:
-# Just returning nothing instead of the SkipTest exception,
-# because the test results in Error in that case.
-# Is that ok?
-# raise unittest.SkipTest("cannot create directory for testing")
- return
-
- def _create_and_do_getcwd(dirname, current_path_length = 0):
- try:
- os.mkdir(dirname)
- except:
- raise unittest.SkipTest("mkdir cannot create directory sufficiently deep for getcwd test")
-
- os.chdir(dirname)
- try:
- os.getcwd()
- if current_path_length < 1027:
- _create_and_do_getcwd(dirname, current_path_length + len(dirname) + 1)
- finally:
- os.chdir('..')
- os.rmdir(dirname)
-
- _create_and_do_getcwd(dirname)
+ try:
+ os.mkdir(base_path)
+ os.chdir(base_path)
+ except:
+ # Just returning nothing instead of the SkipTest exception, because
+ # the test results in Error in that case. Is that ok?
+ # raise unittest.SkipTest("cannot create directory for testing")
+ return
- finally:
- os.chdir(curdir)
- support.rmtree(base_path)
+ def _create_and_do_getcwd(dirname, current_path_length = 0):
+ try:
+ os.mkdir(dirname)
+ except:
+ raise unittest.SkipTest("mkdir cannot create directory sufficiently deep for getcwd test")
+
+ os.chdir(dirname)
+ try:
+ os.getcwd()
+ if current_path_length < 1027:
+ _create_and_do_getcwd(dirname, current_path_length + len(dirname) + 1)
+ finally:
+ os.chdir('..')
+ os.rmdir(dirname)
+
+ _create_and_do_getcwd(dirname)
+
+ finally:
+ os.chdir(curdir)
+ support.rmtree(base_path)
@unittest.skipUnless(hasattr(posix, 'getgrouplist'), "test needs posix.getgrouplist()")
@unittest.skipUnless(hasattr(pwd, 'getpwuid'), "test needs pwd.getpwuid()")
diff --git a/Misc/NEWS b/Misc/NEWS
index 125d604697..53255250e6 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,8 @@ Projected Release date: 2013-09-08
Core and Builtins
-----------------
+- Remove supporting for compiling on systems without getcwd().
+
- Issue #18774: Remove last bits of GNU PTH thread code and thread_pth.h.
- Issue #18771: Add optimization to set object lookups to reduce the cost
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index ab3e9f0b03..fde675284b 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -140,21 +140,18 @@ corresponding Unix manual entries for more information on calls.");
/* Various compilers have only certain posix functions */
/* XXX Gosh I wish these were all moved into pyconfig.h */
#if defined(__WATCOMC__) && !defined(__QNX__) /* Watcom compiler */
-#define HAVE_GETCWD 1
#define HAVE_OPENDIR 1
#define HAVE_SYSTEM 1
#include <process.h>
#else
#ifdef __BORLANDC__ /* Borland compiler */
#define HAVE_EXECV 1
-#define HAVE_GETCWD 1
#define HAVE_OPENDIR 1
#define HAVE_PIPE 1
#define HAVE_SYSTEM 1
#define HAVE_WAIT 1
#else
#ifdef _MSC_VER /* Microsoft compiler */
-#define HAVE_GETCWD 1
#define HAVE_GETPPID 1
#define HAVE_GETLOGIN 1
#define HAVE_SPAWNV 1
@@ -174,7 +171,6 @@ corresponding Unix manual entries for more information on calls.");
#if defined(__USLC__) && defined(__SCO_VERSION__) /* SCO UDK Compiler */
#define HAVE_FORK1 1
#endif
-#define HAVE_GETCWD 1
#define HAVE_GETEGID 1
#define HAVE_GETEUID 1
#define HAVE_GETGID 1
@@ -3179,7 +3175,6 @@ posix_lchown(PyObject *self, PyObject *args)
#endif /* HAVE_LCHOWN */
-#ifdef HAVE_GETCWD
static PyObject *
posix_getcwd(int use_bytes)
{
@@ -3251,7 +3246,6 @@ posix_getcwd_bytes(PyObject *self)
{
return posix_getcwd(1);
}
-#endif
#if ((!defined(HAVE_LINK)) && defined(MS_WINDOWS))
#define HAVE_LINK 1
@@ -10710,12 +10704,10 @@ static PyMethodDef posix_methods[] = {
#ifdef HAVE_CTERMID
{"ctermid", posix_ctermid, METH_NOARGS, posix_ctermid__doc__},
#endif
-#ifdef HAVE_GETCWD
{"getcwd", (PyCFunction)posix_getcwd_unicode,
METH_NOARGS, posix_getcwd__doc__},
{"getcwdb", (PyCFunction)posix_getcwd_bytes,
METH_NOARGS, posix_getcwdb__doc__},
-#endif
#if defined(HAVE_LINK) || defined(MS_WINDOWS)
{"link", (PyCFunction)posix_link,
METH_VARARGS | METH_KEYWORDS,
diff --git a/Python/getcwd.c b/Python/getcwd.c
deleted file mode 100644
index 4bedbd1f75..0000000000
--- a/Python/getcwd.c
+++ /dev/null
@@ -1,83 +0,0 @@
-
-/* Two PD getcwd() implementations.
- Author: Guido van Rossum, CWI Amsterdam, Jan 1991, <guido@cwi.nl>. */
-
-#include <stdio.h>
-#include <errno.h>
-
-#ifdef HAVE_GETWD
-
-/* Version for BSD systems -- use getwd() */
-
-#ifdef HAVE_SYS_PARAM_H
-#include <sys/param.h>
-#endif
-
-#ifndef MAXPATHLEN
-#if defined(PATH_MAX) && PATH_MAX > 1024
-#define MAXPATHLEN PATH_MAX
-#else
-#define MAXPATHLEN 1024
-#endif
-#endif
-
-extern char *getwd(char *);
-
-char *
-getcwd(char *buf, int size)
-{
- char localbuf[MAXPATHLEN+1];
- char *ret;
-
- if (size <= 0) {
- errno = EINVAL;
- return NULL;
- }
- ret = getwd(localbuf);
- if (ret != NULL && strlen(localbuf) >= (size_t)size) {
- errno = ERANGE;
- return NULL;
- }
- if (ret == NULL) {
- errno = EACCES; /* Most likely error */
- return NULL;
- }
- strncpy(buf, localbuf, size);
- return buf;
-}
-
-#else /* !HAVE_GETWD */
-
-/* Version for really old UNIX systems -- use pipe from pwd */
-
-#ifndef PWD_CMD
-#define PWD_CMD "/bin/pwd"
-#endif
-
-char *
-getcwd(char *buf, int size)
-{
- FILE *fp;
- char *p;
- int sts;
- if (size <= 0) {
- errno = EINVAL;
- return NULL;
- }
- if ((fp = popen(PWD_CMD, "r")) == NULL)
- return NULL;
- if (fgets(buf, size, fp) == NULL || (sts = pclose(fp)) != 0) {
- errno = EACCES; /* Most likely error */
- return NULL;
- }
- for (p = buf; *p != '\n'; p++) {
- if (*p == '\0') {
- errno = ERANGE;
- return NULL;
- }
- }
- *p = '\0';
- return buf;
-}
-
-#endif /* !HAVE_GETWD */
diff --git a/configure b/configure
index 55fa2a6957..0f9ba0f46e 100755
--- a/configure
+++ b/configure
@@ -11379,19 +11379,6 @@ esac
fi
-ac_fn_c_check_func "$LINENO" "getcwd" "ac_cv_func_getcwd"
-if test "x$ac_cv_func_getcwd" = xyes; then :
- $as_echo "#define HAVE_GETCWD 1" >>confdefs.h
-
-else
- case " $LIBOBJS " in
- *" getcwd.$ac_objext "* ) ;;
- *) LIBOBJS="$LIBOBJS getcwd.$ac_objext"
- ;;
-esac
-
-fi
-
ac_fn_c_check_func "$LINENO" "strdup" "ac_cv_func_strdup"
if test "x$ac_cv_func_strdup" = xyes; then :
$as_echo "#define HAVE_STRDUP 1" >>confdefs.h
diff --git a/configure.ac b/configure.ac
index 47f5c57924..e329c214cb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3094,7 +3094,7 @@ AC_CHECK_FUNCS(memmove)
# check for long file support functions
AC_CHECK_FUNCS(fseek64 fseeko fstatvfs ftell64 ftello statvfs)
-AC_REPLACE_FUNCS(dup2 getcwd strdup)
+AC_REPLACE_FUNCS(dup2 strdup)
AC_CHECK_FUNCS(getpgrp,
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]], [[getpgrp(0);]])],
[AC_DEFINE(GETPGRP_HAVE_ARG, 1, [Define if getpgrp() must be called as getpgrp(0).])],
diff --git a/pyconfig.h.in b/pyconfig.h.in
index ee5451582a..6dd92505bb 100644
--- a/pyconfig.h.in
+++ b/pyconfig.h.in
@@ -317,9 +317,6 @@
/* Define if you have the getaddrinfo function. */
#undef HAVE_GETADDRINFO
-/* Define to 1 if you have the `getcwd' function. */
-#undef HAVE_GETCWD
-
/* Define this if you have flockfile(), getc_unlocked(), and funlockfile() */
#undef HAVE_GETC_UNLOCKED