pulsar icon indicating copy to clipboard operation
pulsar copied to clipboard

TypeError: Expected str, got bytes

Open x1280 opened this issue 2 years ago • 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

x1280 avatar May 22 '22 07:05 x1280

Hi @x1280, what command triggers the error?

hgascon avatar May 23 '22 08:05 hgascon

pulsar.py -l -p file.pcap

x1280 avatar Jun 07 '22 02:06 x1280

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?

hgascon avatar Jun 07 '22 15:06 hgascon

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)

CSUer2021 avatar Feb 16 '23 02:02 CSUer2021

Would you like to send a pull request?

hgascon avatar Feb 20 '23 10:02 hgascon