kbandla / dpkt

fast, simple packet creation / parsing, with definitions for the basic TCP/IP protocols
Other
1.09k stars 271 forks source link

UnicodeDecodeError in python3.5 #448

Closed gtbaby closed 4 years ago

gtbaby commented 5 years ago

python version: 3.5.3 when I used

f = open('test.pcap')
pcap = dpkt.pcap.Reader(f)

to read the pcap file, some errors appeared like this:

File "/usr/lib/python3.5/codecs.py", line 321, in decode (result, consumed) = self._buffer_decode(data, self.errors, final) UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd4 in position 0: invalid continuation byte

kstiehl commented 5 years ago

Run into the same problem can you tell me how you fixed it?

gtbaby commented 5 years ago

Run into the same problem can you tell me how you fixed it?

I did not fix it. It runs normally in python2. So, you know....

obormot commented 5 years ago

Let's reopen it then

kahramankostas commented 5 years ago

try this: f = open('test.pcap','rb')

It will run :)

obormot commented 4 years ago

Need to open files explicitly in byte mode under py3 for both pcap.Reader and pcap.Writer to work correctly