[issue39430] tarfile.open(mode="r") race condition when importing lzma

2020-01-27 Thread Ethan Furman
Ethan Furman added the comment: Cool. I appreciate all the work in this area, thank you! -- ___ Python tracker ___ ___

[issue39430] tarfile.open(mode="r") race condition when importing lzma

2020-01-27 Thread Brett Cannon
Brett Cannon added the comment: > When was this change made? It has always been this way, so no change here. We have actually improved the situation over the years with attempts at better locking in importlib itself. -- ___ Python tracker

[issue39430] tarfile.open(mode="r") race condition when importing lzma

2020-01-25 Thread Xavier de Gaye
Xavier de Gaye added the comment: This fixed the bug. To reproduce the bug, substitute the "from _lzma import *" statement with "raise ImportError" in Lib/lzma.py to simulate that the _lzma module is missing and run the test.py script written and uploaded by Maciej. --

[issue39430] tarfile.open(mode="r") race condition when importing lzma

2020-01-25 Thread Xavier de Gaye
Xavier de Gaye added the comment: In msg360620 Serhiy wrote: > When the interpreter encounters "import foo" in bar.py, the import machinery > takes the module foo from sys.modules. > So you break an infinite cycle and can import modules with cyclic > dependencies. The following pdb session

[issue39430] tarfile.open(mode="r") race condition when importing lzma

2020-01-24 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I suppose it fixed the bug. But I cannot confirm because I cannot reproduce the original bug. -- ___ Python tracker ___

[issue39430] tarfile.open(mode="r") race condition when importing lzma

2020-01-24 Thread miss-islington
miss-islington added the comment: New changeset 1a274359283d3d1f4f60dd527843f72e0368caf3 by Miss Islington (bot) in branch '3.7': bpo-39430: Fix race condition in lazy imports in tarfile. (GH-18161) https://github.com/python/cpython/commit/1a274359283d3d1f4f60dd527843f72e0368caf3

[issue39430] tarfile.open(mode="r") race condition when importing lzma

2020-01-24 Thread miss-islington
miss-islington added the comment: New changeset ea4a61fec842c94107eef46e5030b89a086f94bb by Miss Islington (bot) in branch '3.8': bpo-39430: Fix race condition in lazy imports in tarfile. (GH-18161) https://github.com/python/cpython/commit/ea4a61fec842c94107eef46e5030b89a086f94bb

[issue39430] tarfile.open(mode="r") race condition when importing lzma

2020-01-24 Thread Ethan Furman
Ethan Furman added the comment: Brett: -- > It's covered in the language reference where import semantics are > explained. It isn't explicitly called out in higher-level docs that > I'm aware of because it only really comes up in edge cases like > importing in a thread which we actively

[issue39430] tarfile.open(mode="r") race condition when importing lzma

2020-01-24 Thread Ethan Furman
Ethan Furman added the comment: New changeset 9017e0bd5e124ae6d2ed94b9e9cacb2e86270980 by Ethan Furman (Serhiy Storchaka) in branch 'master': bpo-39430: Fix race condition in lazy imports in tarfile. (GH-18161) https://github.com/python/cpython/commit/9017e0bd5e124ae6d2ed94b9e9cacb2e86270980

[issue39430] tarfile.open(mode="r") race condition when importing lzma

2020-01-24 Thread miss-islington
Change by miss-islington : -- pull_requests: +17556 pull_request: https://github.com/python/cpython/pull/18171 ___ Python tracker ___

[issue39430] tarfile.open(mode="r") race condition when importing lzma

2020-01-24 Thread miss-islington
Change by miss-islington : -- pull_requests: +17557 pull_request: https://github.com/python/cpython/pull/18172 ___ Python tracker ___

[issue39430] tarfile.open(mode="r") race condition when importing lzma

2020-01-24 Thread Ethan Furman
Ethan Furman added the comment: Thanks, Serhiy! I had no idea of those changes to import. This does raise the question, though, of whether accessing an empty module's attributes should either: - wait for the module to finish initializing; or - raise an exception immediately with better

[issue39430] tarfile.open(mode="r") race condition when importing lzma

2020-01-24 Thread Brett Cannon
Brett Cannon added the comment: It's covered in the language reference where import semantics are explained. It isn't explicitly called out in higher-level docs that I'm aware of because it only really comes up in edge cases like importing in a thread which we actively discourage unless

[issue39430] tarfile.open(mode="r") race condition when importing lzma

2020-01-24 Thread Maciej Gol
Maciej Gol added the comment: This is a HUGE eye opener! Didn't know of that 'import' vs 'from x import y' difference. Thanks a lot! Is it documented somewhere ? pt., 24 sty 2020, 15:08 użytkownik Serhiy Storchaka napisał: > > Serhiy Storchaka added the comment: > > It is intended to

[issue39430] tarfile.open(mode="r") race condition when importing lzma

2020-01-24 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: It is intended to support circular imports. Let foo.py contains "import bar" and bar.py contains "import foo". When you execute "import foo", the import machinery first creates an empty module foo, adds it to sys.modules, reads foo.py and executes it in

[issue39430] tarfile.open(mode="r") race condition when importing lzma

2020-01-24 Thread Maciej Gol
Maciej Gol added the comment: By the way, thanks a lot for the fix <3 -- ___ Python tracker ___ ___ Python-bugs-list mailing list

[issue39430] tarfile.open(mode="r") race condition when importing lzma

2020-01-24 Thread Maciej Gol
Maciej Gol added the comment: > PR 18161 fixes race condition by using "from ... import ..." > which waits until the module be completely initialized if the specified > names are not set. Correct me if I'm wrong, but I think the behavior of 'import lzma' in this case (vulnerable to race

[issue39430] tarfile.open(mode="r") race condition when importing lzma

2020-01-24 Thread Karthikeyan Singaravelan
Change by Karthikeyan Singaravelan : -- nosy: +ethan.furman ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue39430] tarfile.open(mode="r") race condition when importing lzma

2020-01-24 Thread Serhiy Storchaka
Change by Serhiy Storchaka : -- nosy: +brett.cannon, eric.snow, lars.gustaebel, ncoghlan ___ Python tracker ___ ___

[issue39430] tarfile.open(mode="r") race condition when importing lzma

2020-01-24 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: PR 18161 fixes race condition by using "from ... import ..." which waits until the module be completely initialized if the specified names are not set. -- components: +Library (Lib) nosy: +serhiy.storchaka type: crash -> behavior versions: +Python

[issue39430] tarfile.open(mode="r") race condition when importing lzma

2020-01-24 Thread Serhiy Storchaka
Change by Serhiy Storchaka : -- keywords: +patch pull_requests: +17548 stage: -> patch review pull_request: https://github.com/python/cpython/pull/18161 ___ Python tracker

[issue39430] tarfile.open(mode="r") race condition when importing lzma

2020-01-23 Thread Maciej Gol
Maciej Gol added the comment: Uploading fixed file (the former had a typo) -- Added file: https://bugs.python.org/file48861/test.py ___ Python tracker ___

[issue39430] tarfile.open(mode="r") race condition when importing lzma

2020-01-23 Thread Maciej Gol
Change by Maciej Gol : Removed file: https://bugs.python.org/file48860/test.py ___ Python tracker ___ ___ Python-bugs-list mailing list

[issue39430] tarfile.open(mode="r") race condition when importing lzma

2020-01-23 Thread Maciej Gol
New submission from Maciej Gol : Hey guys, We have a component that archives and unarchives multiple files in separate threads that started to misbehave recently. We have noticed a bunch of `AttributeError: module 'lzma' has no attribute 'LZMAFile'` errors, which are unexpected because our