Pcapreader() does not work with PosixPath and WindowsPath fix #3596
Pcapreader() works fine even if the provided filename is in PosixPath or WindowsPath type. Fix #3596
I don't know if this PR requires unit tests. If it does, then please guide me where they can be added.
I didn't know about os.PathLike. It makes perfect sense!
Anyway, not sure it was a good idea after all, since Python 2.7 lacks os.PathLike... Sorry about that :-/
Codecov Report
Merging #3597 (4b1e061) into master (53c764d) will increase coverage by
0.02%. The diff coverage is100.00%.
:exclamation: Current head 4b1e061 differs from pull request most recent head 4f39755. Consider uploading reports for the commit 4f39755 to get more accurate results
@@ Coverage Diff @@
## master #3597 +/- ##
==========================================
+ Coverage 86.19% 86.21% +0.02%
==========================================
Files 284 296 +12
Lines 64874 67082 +2208
==========================================
+ Hits 55915 57832 +1917
- Misses 8959 9250 +291
| Impacted Files | Coverage Δ | |
|---|---|---|
| scapy/libs/six.py | 70.55% <100.00%> (+0.17%) |
:arrow_up: |
| scapy/utils.py | 77.27% <100.00%> (+0.44%) |
:arrow_up: |
| scapy/__init__.py | 74.54% <0.00%> (-8.48%) |
:arrow_down: |
| scapy/layers/ntlm.py | 44.76% <0.00%> (-5.40%) |
:arrow_down: |
| scapy/layers/dhcp.py | 82.67% <0.00%> (-4.61%) |
:arrow_down: |
| scapy/layers/smb.py | 32.37% <0.00%> (-2.12%) |
:arrow_down: |
| scapy/layers/sctp.py | 95.12% <0.00%> (-1.57%) |
:arrow_down: |
| scapy/layers/tls/crypto/cipher_block.py | 96.24% <0.00%> (-1.42%) |
:arrow_down: |
| scapy/contrib/automotive/scanner/enumerator.py | 90.93% <0.00%> (-1.33%) |
:arrow_down: |
| scapy/automaton.py | 74.23% <0.00%> (-1.30%) |
:arrow_down: |
| ... and 169 more |
Sorry, I think it is better to come back to your first option, it was better since it would have worked with Python 2 directly, am I wrong?
Unsure this PR is really necessary: there are quite a few ways to get the full absolute path from the Path... object :/
@gpotter2 The purpose of this PR is to support os.PathLike objects for Pcapreader(). IMHO, they are more useful than strings based paths.
@p-l- My first option would not have worked for Python 2 because the pathlib library was added in Python 3.4
@gpotter2 your call
(As for the doc build failure: https://github.com/sphinx-doc/sphinx/issues/10710)
I am unsure this PR is necessary.
I kinda agree. Are we really going to update every function in Scapy to support path stuff, when in one call you can get the absolute path
I am closing this PR as Scapy maintainers seem that it is not necessary.