[Patches] posixmodulec fails with stat("\\") or stat("/") on Windows.

Mark Hammond mhammond@skippinet.com.au
Wed, 3 May 2000 12:04:13 +1000


Checkin 2.131 of posixmodule.c changed os.stat on Windows, so that
"/bin/" type notation (trailing backslash) would work on Windows to
be consistent with Unix.

However, the patch broke the simple case of: os.stat("\\")

This did work in 1.5.2, and obviously should!

This patch addresses this, and restores the correct behaviour.

diff -c -r2.133 posixmodule.c
*** posixmodule.c	2000/05/01 16:17:24	2.133
--- posixmodule.c	2000/05/03 01:58:57
***************
*** 567,576 ****
  	}

  	if ((pathlen > 0) && (path[pathlen-1] == '\\' || path[pathlen-1]
== '/')) {
! 		/* exception for drive root */
! 		if (!((pathlen == 3) &&
  		      (path[1] == ':') &&
! 		      (path[2] == '\\' || path[2] == '/')))
  		{
  			strncpy(pathcopy, path, pathlen);
  			pathcopy[pathlen-1] = '\0'; /* nuke the trailing backslash */
--- 567,577 ----
  	}

  	if ((pathlen > 0) && (path[pathlen-1] == '\\' || path[pathlen-1]
== '/')) {
! 		/* exception for specific or current drive root */
! 		if (!((pathlen == 1) ||
! 		      ((pathlen == 3) &&
  		      (path[1] == ':') &&
! 		      (path[2] == '\\' || path[2] == '/'))))
  		{
  			strncpy(pathcopy, path, pathlen);
  			pathcopy[pathlen-1] = '\0'; /* nuke the trailing backslash */

Release info:

I confirm that, to the best of my knowledge and belief, this
contribution is free of any claims of third parties under copyright,
patent or other rights or interests ("claims").  To the extent that
I have any such claims, I hereby grant to CNRI a nonexclusive,
irrevocable, royalty-free, worldwide license to reproduce,
distribute, perform and/or display publicly, prepare derivative
versions, and otherwise use this contribution as part of the Python
software and its related documentation, or any derivative versions
thereof, at no cost to CNRI or its licensed users, and to authorize
others to do so.

I acknowledge that CNRI may, at its sole discretion, decide whether
or not to incorporate this contribution in the Python software and
its related documentation.  I further grant CNRI permission to use
my name and other identifying information provided to CNRI by me for
use in connection with the Python software and its related
documentation.

Mark.