TypeError: Expected str, got bytes
x1280 opened this issue · 5 comments
Traceback (most recent call last):
File "pulsar.py", line 98, in
mg.generate_model()
File "/home/x/pulsar/pulsar/core/model.py", line 59, in generate_model
self._generate_model_pcaps()
File "/home/x/pulsar/pulsar/core/model.py", line 76, in _generate_model_pcaps
self._generate_prisma_input(pcap_noext)
File "/home/x/pulsar/pulsar/core/model.py", line 159, in _generate_prisma_input
h.generate_prisma_input(drk_file)
File "/home/x/pulsar/pulsar/core/harry.py", line 88, in generate_prisma_input
doSingleWrite(filteredMessages, base)
File "/home/x/pulsar/pulsar/core/harry.py", line 67, in doSingleWrite
sallyInputFile = sally.rawWrite(fMessages, theBase, self.ngram)
File "/home/x/pulsar/pulsar/core/sally.py", line 36, in rawWrite
return rawWriteText(messages, path)
File "/home/x/pulsar/pulsar/core/sally.py", line 63, in rawWriteText
raw = urllib.parse.unquote(m.msg)
File "/usr/lib/python3.8/urllib/parse.py", line 643, in unquote
raise TypeError('Expected str, got bytes')
TypeError: Expected str, got bytes
ntp.zip
here is the pcap file
pulsar.py -l -p file.pcap
From the urllib.parse.unquote documentation, in
raw = urllib.parse.unquote(m.msg)
m.msg
may be either a str or a bytes object. This was changed in version 3.9: "string parameter supports bytes and str objects (previously only str)". Have you tried to update it?
Hello, i have solved the problem, you can turn m.msg into a str object.
attach my code:
str01 = m.msg.decode(encoding = "utf-8")
raw = urllib.parse.unquote(str01)
Would you like to send a pull request?