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

Avoid copying FieldStorage if possible. #30

Merged
merged 1 commit into from
Aug 29, 2019

Conversation

benjaminp
Copy link
Contributor

On Python 3, cgi.FieldStorage has a del method that closes the underlying file [1]. This means that if the copy made from UnicodeMultiDict._decode_value is garbage collected, the file underlying the original FieldStorage will be closed! Fix this by not copying FieldStorage if it is not required by decode_keys=False. I cannot think of a nice way to fix this problem if decode_keys=True.

[1] python/cpython@f79126f

On Python 3, cgi.FieldStorage has a __del__ method that closes the underlying file [1]. This means that if the copy made from UnicodeMultiDict._decode_value is garbage collected, the file underlying the original FieldStorage will be closed! Fix this by not copying FieldStorage if it is not required by decode_keys=False. I cannot think of a nice way to fix this problem if decode_keys=True.

[1] python/cpython@f79126f
@codecov-io
Copy link

Codecov Report

Merging #30 into master will increase coverage by <.01%.
The diff coverage is 93.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #30      +/-   ##
==========================================
+ Coverage   53.74%   53.75%   +<.01%     
==========================================
  Files         125      125              
  Lines       14785    14790       +5     
  Branches     2499     2500       +1     
==========================================
+ Hits         7946     7950       +4     
+ Misses       6288     6287       -1     
- Partials      551      553       +2
Flag Coverage Δ
#py27 52.69% <86.66%> (ø) ⬆️
#py35 52.03% <60%> (ø) ⬆️
#py36 52.03% <60%> (ø) ⬆️
#py37 52.03% <60%> (ø) ⬆️
#pypy 51.94% <86.66%> (ø) ⬆️
Impacted Files Coverage Δ
tests/test_multidict.py 100% <100%> (ø) ⬆️
paste/util/multidict.py 81.67% <85.71%> (-0.26%) ⬇️
paste/progress.py 0% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9eff34d...b1f9227. Read the comment docs.

1 similar comment
@codecov-io
Copy link

Codecov Report

Merging #30 into master will increase coverage by <.01%.
The diff coverage is 93.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #30      +/-   ##
==========================================
+ Coverage   53.74%   53.75%   +<.01%     
==========================================
  Files         125      125              
  Lines       14785    14790       +5     
  Branches     2499     2500       +1     
==========================================
+ Hits         7946     7950       +4     
+ Misses       6288     6287       -1     
- Partials      551      553       +2
Flag Coverage Δ
#py27 52.69% <86.66%> (ø) ⬆️
#py35 52.03% <60%> (ø) ⬆️
#py36 52.03% <60%> (ø) ⬆️
#py37 52.03% <60%> (ø) ⬆️
#pypy 51.94% <86.66%> (ø) ⬆️
Impacted Files Coverage Δ
tests/test_multidict.py 100% <100%> (ø) ⬆️
paste/util/multidict.py 81.67% <85.71%> (-0.26%) ⬇️
paste/progress.py 0% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9eff34d...b1f9227. Read the comment docs.

@cdent
Copy link
Collaborator

cdent commented Aug 28, 2019

🙈

I'll get to this soon. It's going to take a bit of mental effort to register properly.

@cdent cdent merged commit cdd2a9a into pasteorg:master Aug 29, 2019
@cdent
Copy link
Collaborator

cdent commented Aug 29, 2019

Let me know if you think you'll have a few more of these queued up and I'll hold off on doing a release. Otherwise I'll do one soon.

@benjaminp benjaminp deleted the fieldstorage-copy branch September 4, 2019 02:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants