sniffer in python
peter at engcorp.com
Tue Aug 16 03:24:26 CEST 2005
> Thank you for your fast reply. You're right. I'll be more specific, sorry.
> The example source is the one you can find on the 'Impacket' page on the
> same site of pcapy:
> I use a Win XP prof sp2 system, python ver. 2.4.1.
> Here's the output:
> Traceback (most recent call last):
> File "C:\Python24\1.py", line 107, in ?
> File "C:\Python24\1.py", line 88, in main
> dev = getInterface()
> File "C:\Python24\1.py", line 81, in getInterface
> print '%i - %s' % (count, iface)
> File "C:\Python23\lib\encodings\cp850.py", line 18, in encode
> return codecs.charmap_encode(input,errors,encoding_map)
> UnicodeEncodeError: 'charmap' codec can't encode characters in position
> 4-19: ch
> aracter maps to <undefined>
Helping you learn to troubleshoot from tracebacks: look at the line
preceding the failing call. Can you guess anything about what in that
line might be causing an encode() call? The count variable is,
presumably, just an integer, so %i wouldn't like have to do more than
convert it to a string. %s, however, asks for "iface" to be turned into
a string... if it were not already a string (i.e. it's a unicode?) it
would have to be encoded. What does iface contain and where did it come
from? Can you make it be just a string? Does that change or fix anything?
More information about the Python-list