bpo-34580: Clarify calling close when connection is used in a context manager#9079
Conversation
This reverts commit 7e469c1.
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
|
I have made the requested changes; please review again |
|
Thanks for making the requested changes! @berkerpeksag: please review the changes made to this pull request. |
|
I have deleted the unused files and added comments about usage of One thing I noticed with the backup example was that connection object was initialized in the context manager itself thus the commit would be called but the connection object will be de-allocated without closing the connection. I hope I am correct here given my understanding of the PR and context managers. So I have changed the current example Current example : con = sqlite3.connect('existing_db.db')
with sqlite3.connect('backup.db') as bck:
con.backup(bck, pages=1, progress=progress)Example in the PR : con = sqlite3.connect('existing_db.db')
bck = sqlite3.connect('backup.db')
with bck:
con.backup(bck, pages=1, progress=progress)
bck.close()
con.close()Apologies for multiple commits that might have spammed you after notifying with the bot. I added Thanks for the review! |
|
Friendly ping @berkerpeksag :) |
|
Thanks @tirkarthi for the PR, and @berkerpeksag for merging it 🌮🎉.. I'm working now to backport this PR to: 3.7. |
|
GH-13429 is a backport of this pull request to the 3.7 branch. |
Add an extra note that the connection object doesn't call
closein a context manager.Thanks
https://bugs.python.org/issue34580