-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Backward compatibility: Add Deprecated fields #1983
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1983 +/- ##
==========================================
- Coverage 87.18% 86.44% -0.75%
==========================================
Files 197 197
Lines 44486 44507 +21
==========================================
- Hits 38787 38472 -315
- Misses 5699 6035 +336
|
@@ -84,7 +85,11 @@ def _read_config_file(cf, _globals=globals(), _locals=locals(), interactive=True | |||
""" | |||
log_loading.debug("Loading config file [%s]", cf) | |||
try: | |||
exec(compile(open(cf).read(), cf, 'exec'), _globals, _locals) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Random unclosed file triggered by the new detection
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK
Also ready despite the failing codecov test |
I like this idea but I have some comments:
|
Thanks for the suggestions, I've updated the PR. So you think that we should allow |
Throwing the exception is IMHO the only valid option to warn users =)
|
Got it, updated (Please squash when merging) |
@guedou This is ready for review ! |
scapy/layers/dot11.py
Outdated
@@ -247,6 +247,11 @@ def guess_payload_class(self, pay): | |||
|
|||
class RadioTap(Packet): | |||
name = "RadioTap dummy" | |||
deprecated_fields = { | |||
"Channel": "ChannelFrequency", # 2.4.3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if the version should be part of the deprecation API. It might ease our future selves while debugging issues =)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, will do
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have to think about it, but the idea is nice. Here is a change suggestion to make the code simpler.
Co-Authored-By: Pierre Lalet <[email protected]>
Rationale: Scapy is pretty bad at keeping things backward compatible. Fields are renamed often for consistency, therefore breaking older stuff. Moreover, because the release schedule is so slow, people aren't warned of changes.
This PR is an attempt to improve this by:
alias_fields
that redirects to another field with an optionalDeprecationWarning
. We already have use cases for that: RadioTap Dummy Channel vs. Frequency confusion #1979 Bluetooth LE: multiple improvements #1855. This would allow to migrate old scapy fields to newer names, without breaking too much stuff too quicklyNot sure how this affects performance. Adding stuff to
get_field
& co never is great