diff -r c1c45755397b Lib/test/test_posix.py --- a/Lib/test/test_posix.py Tue Aug 21 19:44:00 2012 +0200 +++ b/Lib/test/test_posix.py Fri Aug 24 15:22:21 2012 +0000 @@ -405,8 +405,16 @@ _create_and_do_getcwd(dirname, current_path_length + len(dirname) + 1) except OSError as e: expected_errno = errno.ENAMETOOLONG - if 'sunos' in sys.platform or 'openbsd' in sys.platform: - expected_errno = errno.ERANGE # Issue 9185 + # The following platforms have quirky getcwd() + # behaviour -- see issue 9185 and 15765 for + # more information. + quirky_platform = ( + 'sunos' in sys.platform or + 'netbsd' in sys.platform or + 'openbsd' in sys.platform + ) + if quirky_platform: + expected_errno = errno.ERANGE self.assertEqual(e.errno, expected_errno) finally: os.chdir('..') diff -r c1c45755397b Modules/posixmodule.c --- a/Modules/posixmodule.c Tue Aug 21 19:44:00 2012 +0200 +++ b/Modules/posixmodule.c Fri Aug 24 15:22:21 2012 +0000 @@ -1956,7 +1956,9 @@ "getcwd() -> path\n\n\ Return a string representing the current working directory."); -#if (defined(__sun) && defined(__SVR4)) || defined(__OpenBSD__) +#if (defined(__sun) && defined(__SVR4)) || \ + defined(__OpenBSD__) || \ + defined(__NetBSD__) /* Issue 9185: getcwd() returns NULL/ERANGE indefinitely. */ static PyObject * posix_getcwd(PyObject *self, PyObject *noargs)