<html>
<head>
<style>
P
{
margin:0px;
padding:0px
}
body
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body>I grabbed the latest Python2.5 code via subversion and ran my typo script on it.<BR>
&nbsp;<BR>
Weeding out the obvious false positives and Neal's comments leaves about 129 typos.<BR>
&nbsp;<BR>
See <A href="http://www.geocities.com/typopl/typoscan.htm">http://www.geocities.com/typopl/typoscan.htm</A><BR>
&nbsp;<BR>
Should I enter the typos as bugs in the Python bug db?<BR>
<BR>J<BR>
<BR>
<HR id=stopSpelling>
<BR>
&gt; Date: Fri, 22 Sep 2006 21:51:38 -0700<BR>&gt; From: nnorwitz@gmail.com<BR>&gt; To: typo_pl@hotmail.com<BR>&gt; Subject: Re: [Python-Dev] Typo.pl scan of Python 2.5 source code<BR>&gt; CC: python-dev@python.org<BR>&gt; <BR>&gt; On 9/22/06, Johnny Lee &lt;typo_pl@hotmail.com&gt; wrote:<BR>&gt; &gt;<BR>&gt; &gt; Hello,<BR>&gt; &gt; My name is Johnny Lee. I have developed a *ahem* perl script which scans<BR>&gt; &gt; C/C++ source files for typos.<BR>&gt; <BR>&gt; Hi Johnny.<BR>&gt; <BR>&gt; Thanks for running your script, even if it is written in Perl and ran<BR>&gt; on Windows. :-)<BR>&gt; <BR>&gt; &gt; The Python 2.5 typos can be classified into 7 types.<BR>&gt; &gt;<BR>&gt; &gt; 2) realloc overwrite src if NULL, i.e. p = realloc(p, new_size);<BR>&gt; &gt; If realloc() fails, it will return NULL. If you assign the return value to<BR>&gt; &gt; the same variable you passed into realloc,<BR>&gt; &gt; then you've overwritten the variable and possibly leaked the memory that the<BR>&gt; &gt; variable pointed to.<BR>&gt; <BR>&gt; A bunch of these warnings were accurate and a bunch were not. There<BR>&gt; were 2 reasons for the false positives. 1) The pointer was aliased,<BR>&gt; thus not lost, 2) On failure, we exited (Parser/*.c)<BR>&gt; <BR>&gt; &gt; 4) if ((X!=0) || (X!=1))<BR>&gt; <BR>&gt; These 2 cases occurred in binascii. I have no idea if the warning is<BR>&gt; wright or the code is.<BR>&gt; <BR>&gt; &gt; 6) XX;;<BR>&gt; &gt; Just being anal here. Two semicolons in a row. Second one is extraneous.<BR>&gt; <BR>&gt; I already checked in a fix for these on HEAD. Hard for even me to<BR>&gt; screw up those fixes. :-)<BR>&gt; <BR>&gt; &gt; 7) extraneous test for non-NULL ptr<BR>&gt; &gt; Several memory calls that free memory accept NULL ptrs.<BR>&gt; &gt; So testing for NULL before calling them is redundant and wastes code space.<BR>&gt; &gt; Now some codepaths may be time-critical, but probably not all, and smaller<BR>&gt; &gt; code usually helps.<BR>&gt; <BR>&gt; I ignored these as I'm not certain all the platforms we run on accept<BR>&gt; free(NULL).<BR>&gt; <BR>&gt; Below is my categorization of the warnings except #7. Hopefully<BR>&gt; someone will fix all the real problems in the first batch.<BR>&gt; <BR>&gt; Thanks again!<BR>&gt; <BR>&gt; n<BR>&gt; --<BR>&gt; <BR>&gt; # Problems<BR>&gt; Objects\fileobject.c (338): realloc overwrite src if NULL; 17:<BR>&gt; file-&gt;f_setbuf=(char*)PyMem_Realloc(file-&gt;f_setbuf,bufsize)<BR>&gt; Objects\fileobject.c (342): using PyMem_Realloc result w/no check<BR>&gt; 30: setvbuf(file-&gt;f_fp, file-&gt;f_setbuf, type, bufsize);<BR>&gt; [file-&gt;f_setbuf]<BR>&gt; Objects\listobject.c (2619): using PyMem_MALLOC result w/no check<BR>&gt; 30: garbage[i] = selfitems[cur]; [garbage]<BR>&gt; Parser\myreadline.c (144): realloc overwrite src if NULL; 17:<BR>&gt; p=(char*)PyMem_REALLOC(p,n+incr)<BR>&gt; Modules\_csv.c (564): realloc overwrite src if NULL; 17:<BR>&gt; self-&gt;field=PyMem_Realloc(self-&gt;field,self-&gt;field_size)<BR>&gt; Modules\_localemodule.c (366): realloc overwrite src if NULL; 17:<BR>&gt; buf=PyMem_Realloc(buf,n2)<BR>&gt; Modules\_randommodule.c (290): realloc overwrite src if NULL; 17:<BR>&gt; key=(unsigned#long*)PyMem_Realloc(key,bigger*sizeof(*key))<BR>&gt; Modules\arraymodule.c (1675): realloc overwrite src if NULL; 17:<BR>&gt; self-&gt;ob_item=(char*)PyMem_REALLOC(self-&gt;ob_item,itemsize*self-&gt;ob_size)<BR>&gt; Modules\cPickle.c (536): realloc overwrite src if NULL; 17:<BR>&gt; self-&gt;buf=(char*)realloc(self-&gt;buf,n)<BR>&gt; Modules\cPickle.c (592): realloc overwrite src if NULL; 17:<BR>&gt; self-&gt;buf=(char*)realloc(self-&gt;buf,bigger)<BR>&gt; Modules\cPickle.c (4369): realloc overwrite src if NULL; 17:<BR>&gt; self-&gt;marks=(int*)realloc(self-&gt;marks,s*sizeof(int))<BR>&gt; Modules\cStringIO.c (344): realloc overwrite src if NULL; 17:<BR>&gt; self-&gt;buf=(char*)realloc(self-&gt;buf,self-&gt;buf_size)<BR>&gt; Modules\cStringIO.c (380): realloc overwrite src if NULL; 17:<BR>&gt; oself-&gt;buf=(char*)realloc(oself-&gt;buf,oself-&gt;buf_size)<BR>&gt; Modules\_ctypes\_ctypes.c (2209): using PyMem_Malloc result w/no<BR>&gt; check 30: memset(obj-&gt;b_ptr, 0, dict-&gt;size); [obj-&gt;b_ptr]<BR>&gt; Modules\_ctypes\callproc.c (1472): using PyMem_Malloc result w/no<BR>&gt; check 30: strcpy(conversion_mode_encoding, coding);<BR>&gt; [conversion_mode_encoding]<BR>&gt; Modules\_ctypes\callproc.c (1478): using PyMem_Malloc result w/no<BR>&gt; check 30: strcpy(conversion_mode_errors, mode);<BR>&gt; [conversion_mode_errors]<BR>&gt; Modules\_ctypes\stgdict.c (362): using PyMem_Malloc result w/no<BR>&gt; check 30: memset(stgdict-&gt;ffi_type_pointer.elements, 0,<BR>&gt; [stgdict-&gt;ffi_type_pointer.elements]<BR>&gt; Modules\_ctypes\stgdict.c (376): using PyMem_Malloc result w/no<BR>&gt; check 30: memset(stgdict-&gt;ffi_type_pointer.elements, 0,<BR>&gt; [stgdict-&gt;ffi_type_pointer.elements]<BR>&gt; <BR>&gt; # No idea if the code or tool is right.<BR>&gt; Modules\binascii.c (1161)<BR>&gt; Modules\binascii.c (1231)<BR>&gt; <BR>&gt; # Platform specific files. I didn't review and won't fix without testing.<BR>&gt; Python\thread_lwp.h (107): using malloc result w/no check 30:<BR>&gt; lock-&gt;lock_locked = 0; [lock]<BR>&gt; Python\thread_os2.h (141): using malloc result w/no check 30:<BR>&gt; (long)sem)); [sem]<BR>&gt; Python\thread_os2.h (155): using malloc result w/no check 30:<BR>&gt; lock-&gt;is_set = 0; [lock]<BR>&gt; Python\thread_pth.h (133): using malloc result w/no check 30:<BR>&gt; memset((void *)lock, '\0', sizeof(pth_lock)); [lock]<BR>&gt; Python\thread_solaris.h (48): using malloc result w/no check 30:<BR>&gt; funcarg-&gt;func = func; [funcarg]<BR>&gt; Python\thread_solaris.h (133): using malloc result w/no check 30:<BR>&gt; if(mutex_init(lock,USYNC_THREAD,0)) [lock]<BR>&gt; <BR>&gt; # Who cares about these modules.<BR>&gt; Modules\almodule.c:182<BR>&gt; Modules\svmodule.c:547<BR>&gt; <BR>&gt; # Not a problem.<BR>&gt; Parser\firstsets.c (76)<BR>&gt; Parser\grammar.c (40)<BR>&gt; Parser\grammar.c (59)<BR>&gt; Parser\grammar.c (83)<BR>&gt; Parser\grammar.c (102)<BR>&gt; Parser\node.c (95)<BR>&gt; Parser\pgen.c (52)<BR>&gt; Parser\pgen.c (69)<BR>&gt; Parser\pgen.c (126)<BR>&gt; Parser\pgen.c (438)<BR>&gt; Parser\pgen.c (462)<BR>&gt; Parser\tokenizer.c (797)<BR>&gt; Parser\tokenizer.c (869)<BR>&gt; Modules\_bsddb.c (2633)<BR>&gt; Modules\_csv.c (1069)<BR>&gt; Modules\arraymodule.c (1871)<BR>&gt; Modules\gcmodule.c (1363)<BR>&gt; Modules\zlib\trees.c (375)<BR><BR><br /><hr />Get the new Windows Live Messenger! <a href='http://get.live.com/messenger/overview' target='_new'>Try it!</a></body>
</html>