Update of /cvsroot/pywin32/pywin32/com/win32com/client
In directory sc8-pr-cvs1:/tmp/cvs-serv29800
Modified Files:
build.py
Log Message:
Don't let a gen_py created file overwrite a builtin (such as None!)
Index: build.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/com/win32com/client/build.py,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -d -r1.23 -r1.24
*** build.py 18 Mar 2003 07:12:10 -0000 1.23
--- build.py 23 Oct 2003 07:15:30 -0000 1.24
***************
*** 495,506 ****
# make sure it is a legal (and reasonable!) Python name.
def MakePublicAttributeName(className):
! # Given a class attribute that needs to be public, but Python munges
! # convert it. Also need to be careful that the munging doesnt
# create duplicates - eg, just removing a leading "_" is likely to cause
# a clash.
if className[:2]=='__' and className[-2:]!='__':
return className[1:] + '_' # First '_' moved at the end.
! elif iskeyword(className):
return string.capitalize(className)
# Strip non printable chars
return filter( lambda char: char in valid_identifier_chars, className)
--- 495,514 ----
# make sure it is a legal (and reasonable!) Python name.
def MakePublicAttributeName(className):
! # Given a class attribute that needs to be public, convert it to a
! # reasonable name.
! # Also need to be careful that the munging doesnt
# create duplicates - eg, just removing a leading "_" is likely to cause
# a clash.
if className[:2]=='__' and className[-2:]!='__':
return className[1:] + '_' # First '_' moved at the end.
! elif iskeyword(className): # all keywords are lower case
return string.capitalize(className)
+ elif __builtins__.has_key(className):
+ # builtins may be mixed case. If capitalizing it doesn't change it,
+ # force to all uppercase (eg, "None", "True" become "NONE", "TRUE"
+ ret = className.capitalize()
+ if ret==className: # didn't change - force all uppercase.
+ ret = ret.upper()
+ return ret
# Strip non printable chars
return filter( lambda char: char in valid_identifier_chars, className)
|