Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Expected str, got bytes #31

Open
x1280 opened this issue May 22, 2022 · 5 comments
Open

TypeError: Expected str, got bytes #31

x1280 opened this issue May 22, 2022 · 5 comments

Comments

@x1280
Copy link

x1280 commented May 22, 2022

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

@hgascon
Copy link
Owner

hgascon commented May 23, 2022

Hi @x1280, what command triggers the error?

@x1280
Copy link
Author

x1280 commented Jun 7, 2022

pulsar.py -l -p file.pcap

@hgascon
Copy link
Owner

hgascon commented Jun 7, 2022

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?

@CSUer2021
Copy link

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)

@hgascon
Copy link
Owner

hgascon commented Feb 20, 2023

Would you like to send a pull request?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants