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

PicklingError when saving a session #4245

Closed
StragaSevera opened this issue Feb 1, 2024 · 1 comment · Fixed by #4368
Closed

PicklingError when saving a session #4245

StragaSevera opened this issue Feb 1, 2024 · 1 comment · Fixed by #4368
Labels
Milestone

Comments

@StragaSevera
Copy link

Brief description

Whenever I try to save a session (either via exiting from scapy started with -s flag, or by using save_session function), I receive error: PicklingError: Can't pickle <function open at 0x7212fd7be680>: it's not the same object as io.open.

Scapy version

2.5.0 (both with pip version and with 277f3 commit)

Python version

3.10

Operating system

Arch Linux

Additional environment information

No response

How to reproduce

Either:

  1. Start a shell without -s flag.
  2. Type: save_session("01")

Or:

  1. Start a shell with -s 01 flag.
  2. Type exit()

Actual result

In first case, the log is:

sudo -E scapy -H
Welcome to Scapy (2.5.0.dev230) using IPython 8.21.0
>>> save_session("01")
INFO: Saving session into [01]
---------------------------------------------------------------------------
PicklingError                             Traceback (most recent call last)
Cell In[1], line 1
----> 1 save_session("01")

File ~/.asdf/installs/python/3.10.13/lib/python3.10/site-packages/scapy/main.py:425, in save_session(fname, session, pickleProto)
    422     pass
    424 f = gzip.open(fname, "wb")
--> 425 pickle.dump(to_be_saved, f, pickleProto)
    426 f.close()

PicklingError: Can't pickle <function open at 0x7ea2845b6680>: it's not the same object as io.open
>>>        

In second case, the log is:

sudo -E scapy -H -s 01
Welcome to Scapy (2.5.0.dev230) using IPython 8.21.0
>>> %config Application.verbose_crash=True
>>> exit
INFO: Saving session into [01]
Error in sys.excepthook:
Traceback (most recent call last):
  File "/home/ought/.asdf/installs/python/3.10.13/lib/python3.10/pathlib.py", line 1305, in is_dir
    return S_ISDIR(self.stat().st_mode)
AttributeError: 'str' object has no attribute 'stat'

Original exception was:
Traceback (most recent call last):
  File "/home/ought/.asdf/installs/python/3.10.13/bin/scapy", line 8, in <module>
    sys.exit(interact())
  File "/home/ought/.asdf/installs/python/3.10.13/lib/python3.10/site-packages/scapy/main.py", line 933, in interact
    save_session(conf.session, SESSION)
  File "/home/ought/.asdf/installs/python/3.10.13/lib/python3.10/site-packages/scapy/main.py", line 425, in save_session
    pickle.dump(to_be_saved, f, pickleProto)
_pickle.PicklingError: Can't pickle <function open at 0x79c2b3f42680>: it's not the same object as io.open

Expected result

No response

Related resources

No response

@gpotter2 gpotter2 added the bug label Feb 18, 2024
@gpotter2 gpotter2 added this to the 2.6.0 milestone Mar 16, 2024
@gpotter2
Copy link
Member

Thanks for the report. This is fixed in #4368

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

Successfully merging a pull request may close this issue.

2 participants