File tree 3 files changed +18
-3
lines changed 3 files changed +18
-3
lines changed Original file line number Diff line number Diff line change 11
11
12
12
- Switch from ` openssl ` to ` rustls ` in ` attohttpc ` dependency. [ #49 ] ( https://github.com/Stranger6667/css-inline/issues/49 )
13
13
14
+
15
+ ### Performance
16
+
17
+ - Use ` ToString ` trait during error handling to avoid using a formatter.
18
+
14
19
## [ 0.3.2] - 2020-07-09
15
20
16
21
### Fixed
Original file line number Diff line number Diff line change 1
1
import multiprocessing
2
+ from contextlib import suppress
2
3
3
4
import inlinestyler .utils
4
5
import premailer
@@ -204,3 +205,12 @@ def test_realistic(benchmark, func):
204
205
@pytest .mark .benchmark (group = "realistic many" )
205
206
def test_realistic_many (benchmark , func ):
206
207
benchmark (func , REALISTIC_HTMLS )
208
+
209
+
210
+ @pytest .mark .benchmark (group = "exception" )
211
+ def test_exception (benchmark ):
212
+ def func ():
213
+ with suppress (ValueError ):
214
+ css_inline .inline ("" , base_url = "!wrong!" )
215
+
216
+ benchmark (func )
Original file line number Diff line number Diff line change @@ -13,8 +13,8 @@ struct InlineErrorWrapper(rust_inline::InlineError);
13
13
impl From < InlineErrorWrapper > for PyErr {
14
14
fn from ( error : InlineErrorWrapper ) -> Self {
15
15
match error. 0 {
16
- rust_inline:: InlineError :: IO ( error) => InlineError :: py_err ( format ! ( "{}" , error) ) ,
17
- rust_inline:: InlineError :: Network ( error) => InlineError :: py_err ( format ! ( "{}" , error) ) ,
16
+ rust_inline:: InlineError :: IO ( error) => InlineError :: py_err ( error. to_string ( ) ) ,
17
+ rust_inline:: InlineError :: Network ( error) => InlineError :: py_err ( error. to_string ( ) ) ,
18
18
rust_inline:: InlineError :: ParseError ( message) => InlineError :: py_err ( message) ,
19
19
}
20
20
}
@@ -24,7 +24,7 @@ struct UrlError(url::ParseError);
24
24
25
25
impl From < UrlError > for PyErr {
26
26
fn from ( error : UrlError ) -> Self {
27
- exceptions:: ValueError :: py_err ( format ! ( "{}" , error. 0 ) )
27
+ exceptions:: ValueError :: py_err ( error. 0 . to_string ( ) )
28
28
}
29
29
}
30
30
You can’t perform that action at this time.
0 commit comments