-
-
Notifications
You must be signed in to change notification settings - Fork 219
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
Brotli: Don't accept brotli if library can't be loaded. #444
Conversation
and also remove 'br' from any Accept-Encoding to avoid recording with brotli, addresses #434
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.
Other than the small bare exception nit this PR LGTM 👍
pywb/rewrite/rewriteinputreq.py
Outdated
try: # pragma: no cover | ||
import brotli | ||
has_brotli = True | ||
except: # pragma: no cover |
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 think it would be good practice to start using named exceptions when possible.
Here it would be except ImportError
in order to be clearer about why we expect an exception and to be pythonic :)
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.
In general, yes, but here want to catch any Exception
as that means brotli is not properly installed. Added Exception
Codecov Report
@@ Coverage Diff @@
## develop #444 +/- ##
===========================================
+ Coverage 87.83% 87.84% +<.01%
===========================================
Files 59 59
Lines 7236 7239 +3
Branches 1288 1290 +2
===========================================
+ Hits 6356 6359 +3
Misses 585 585
Partials 295 295
Continue to review full report at Codecov.
|
…be gain performance increases (https://docs.python.org/3/faq/programming.html#id37) Changed the caught exception in try_brotli_init from ImportError to Exception due to finding causing pywb PR #444 (webrecorder/pywb#444)
Description
If
import brotli
fails, print warning and removebr
fromAccept-Encoding
Otherwise, can fail silently when trying to record/replay brotli content.
Motivation and Context
See #434
Screenshots (if appropriate):
Types of changes
Checklist: