Index: posixmodule.c =================================================================== --- posixmodule.c (revision 83403) +++ posixmodule.c (working copy) @@ -8205,12 +8205,41 @@ NULL }; +/* + Rather than check for the existence of the Symlink implementation when + os.symlink is called, instead omit it from the module at init time if it + is not going to be available +*/ +void RemoveSymlinkIfNotImplemented() +{ +#if !defined(HAVE_SYMLINK) && defined(MS_WINDOWS) + int method_index = 0; + if(check_CreateSymbolicLinkW()) + { + # we have symbolic links, so do nothing + return; + } + /* find the symlink method */ + while(posix_methods[method_index].ml_func != (PyCFunction)win_symlink) + { + method_index++; + } + /* now shift the rest of the methods up one, overwriting symlink */ + while(posix_methods[method_index] != NULL) + { + posix_methods[method_index] = posix_methods[method_index+1]; + } +#endif /* !defined(HAVE_SYMLINK) && defined(MS_WINDOWS) */ +} + PyMODINIT_FUNC INITFUNC(void) { PyObject *m, *v; + RemoveSymlinkIfNotImplemented(); + m = PyModule_Create(&posixmodule); if (m == NULL) return NULL;