[Python-Dev] nondist/sandbox/typecheck
Paul Prescod
paulp@ActiveState.com
Mon, 19 Mar 2001 09:55:36 -0800
Could I check in some type-checking code into nondist/sandbox? It's
quickly getting to the point where real users can start to see benefits
from it and I would like to let people play with it to convince
themselves of that.
Consider these mistaken statements:
os.path.abspath(None)
xmllib.XMLParser().feed(None)
sre.compile(".*", "I")
Here's what we used to get as tracebacks:
os.path.abspath(None)
(no error, any falsible value is treated as the same as the empty
string!)
xmllib.XMLParser().feed(None)
Traceback (most recent call last):
File "errors.py", line 8, in ?
xmllib.XMLParser().feed(None)
File "c:\python20\lib\xmllib.py", line 164, in feed
self.rawdata = self.rawdata + data
TypeError: cannot add type "None" to string
sre.compile(".*", "I")
Traceback (most recent call last):
File "errors.py", line 12, in ?
sre.compile(".*", "I")
File "c:\python20\lib\sre.py", line 62, in compile
return _compile(pattern, flags)
File "c:\python20\lib\sre.py", line 100, in _compile
p = sre_compile.compile(pattern, flags)
File "c:\python20\lib\sre_compile.py", line 359, in compile
p = sre_parse.parse(p, flags)
File "c:\python20\lib\sre_parse.py", line 586, in parse
p = _parse_sub(source, pattern, 0)
File "c:\python20\lib\sre_parse.py", line 294, in _parse_sub
items.append(_parse(source, state))
File "c:\python20\lib\sre_parse.py", line 357, in _parse
if state.flags & SRE_FLAG_VERBOSE:
TypeError: bad operand type(s) for &
====================
Here's what we get now:
os.path.abspath(None)
Traceback (most recent call last):
File "errors.py", line 4, in ?
os.path.abspath(None)
File "ntpath.py", line 401, in abspath
def abspath(path):
InterfaceError: Parameter 'path' expected Unicode or 8-bit string.
Instead it got 'None' (None)
xmllib.XMLParser().feed(None)
Traceback (most recent call last):
File "errors.py", line 8, in ?
xmllib.XMLParser().feed(None)
File "xmllib.py", line 163, in feed
def feed(self, data):
InterfaceError: Parameter 'data' expected Unicode or 8-bit string.
Instead it got 'None' (None)
sre.compile(".*", "I")
Traceback (most recent call last):
File "errors.py", line 12, in ?
sre.compile(".*", "I")
File "sre.py", line 61, in compile
def compile(pattern, flags=0):
InterfaceError: Parameter 'flags' expected None.
Instead it got 'string' ('I')
None
--
Take a recipe. Leave a recipe.
Python Cookbook! http://www.activestate.com/pythoncookbook