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