Issue36688
Created on 2019-04-21 06:20 by xtreak, last changed 2022-04-11 14:59 by admin. This issue is now closed.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 12943 | merged | python-dev, 2019-04-24 19:18 | |
| PR 14144 | merged | miss-islington, 2019-06-17 08:10 | |
| PR 14145 | merged | miss-islington, 2019-06-17 08:10 | |
| Messages (9) | |||
|---|---|---|---|
| msg340597 - (view) | Author: Karthikeyan Singaravelan (xtreak) * | Date: 2019-04-21 06:20 | |
importing dummy_threading causes ImportError. It used to work on 3.6. There are tests at Lib/test/test_dummy_threading.py and rearranging the import so that "import dummy_threading as _threading" is the first line also causes error. This module was deprecated from 3.7 with respect to threading enabled always but I thought to add a report anyway. Looking at git log it seems a6a4dc816d68df04a7d592e0b6af8c7ecc4d4344 did some changes where catching the ImportError on Lib/functools.py was removed that could be causing this issue. Importing functools before dummy_threading works. # master with functools imported before dummy_threading ➜ cpython git:(master) ✗ ./python.exe -c 'import functools; import dummy_threading; print("hello")' hello # Python 3.6 $ python3.6 -c 'import dummy_threading; print("hello")' hello # Python 3.7 $ python3.7 -c 'import dummy_threading' Traceback (most recent call last): File "<string>", line 1, in <module> File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/dummy_threading.py", line 45, in <module> import threading File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py", line 8, in <module> from traceback import format_exc as _format_exc File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/traceback.py", line 5, in <module> import linecache File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/linecache.py", line 8, in <module> import functools File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/functools.py", line 24, in <module> from _thread import RLock ImportError: cannot import name 'RLock' from '_dummy_thread' (/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/_dummy_thread.py) # master $ cpython git:(master) ./python.exe -c 'import dummy_threading' Traceback (most recent call last): File "<string>", line 1, in <module> File "/Users/karthikeyansingaravelan/stuff/python/cpython/Lib/dummy_threading.py", line 45, in <module> import threading File "/Users/karthikeyansingaravelan/stuff/python/cpython/Lib/threading.py", line 8, in <module> from traceback import format_exc as _format_exc File "/Users/karthikeyansingaravelan/stuff/python/cpython/Lib/traceback.py", line 5, in <module> import linecache File "/Users/karthikeyansingaravelan/stuff/python/cpython/Lib/linecache.py", line 8, in <module> import functools File "/Users/karthikeyansingaravelan/stuff/python/cpython/Lib/functools.py", line 20, in <module> from _thread import RLock ImportError: cannot import name 'RLock' from '_dummy_thread' (/Users/karthikeyansingaravelan/stuff/python/cpython/Lib/_dummy_thread.py) # Patch to move dummy_threading import as first line diff --git a/Lib/test/test_dummy_threading.py b/Lib/test/test_dummy_threading.py index a0c2972a60..dc40abeda5 100644 --- a/Lib/test/test_dummy_threading.py +++ b/Lib/test/test_dummy_threading.py @@ -1,6 +1,6 @@ +import dummy_threading as _threading from test import support import unittest -import dummy_threading as _threading import time class DummyThreadingTestCase(unittest.TestCase): ➜ cpython git:(master) ✗ ./python.exe Lib/test/test_dummy_threading.py Traceback (most recent call last): File "Lib/test/test_dummy_threading.py", line 1, in <module> import dummy_threading as _threading File "/Users/karthikeyansingaravelan/stuff/python/cpython/Lib/dummy_threading.py", line 45, in <module> import threading File "/Users/karthikeyansingaravelan/stuff/python/cpython/Lib/threading.py", line 8, in <module> from traceback import format_exc as _format_exc File "/Users/karthikeyansingaravelan/stuff/python/cpython/Lib/traceback.py", line 5, in <module> import linecache File "/Users/karthikeyansingaravelan/stuff/python/cpython/Lib/linecache.py", line 8, in <module> import functools File "/Users/karthikeyansingaravelan/stuff/python/cpython/Lib/functools.py", line 20, in <module> from _thread import RLock ImportError: cannot import name 'RLock' from '_dummy_thread' (/Users/karthikeyansingaravelan/stuff/python/cpython/Lib/_dummy_thread.py) |
|||
| msg340681 - (view) | Author: Brett Cannon (brett.cannon) * | Date: 2019-04-22 19:35 | |
Basically _thread.RLock was added without an equivalent in _dummy_thread. Add that and it will fix the issue. It probably wouldn't be too hard since you have to implement it as if it's single-threaded and there's already a lock class in _dummy_thread to work off of. Heck, functools used to have its own dummy version in https://github.com/python/cpython/commit/a6a4dc816d68df04a7d592e0b6af8c7ecc4d4344 but it got ripped out, although it was extremely basic so I don't know if it would be the best version to put into _dummy_thread. |
|||
| msg345804 - (view) | Author: Ned Deily (ned.deily) * | Date: 2019-06-17 07:31 | |
Ping. This was marked as a 3.7regression and there is a PR waiting for review. Do we have plans to remove _dummy_thread in 3.8 or 3.9? |
|||
| msg345812 - (view) | Author: STINNER Victor (vstinner) * | Date: 2019-06-17 08:08 | |
I created bpo-37312: "Remove deprecated _dummy_thread and dummy_threading modules" (in Python 3.9). |
|||
| msg345813 - (view) | Author: STINNER Victor (vstinner) * | Date: 2019-06-17 08:10 | |
New changeset c5905f39bcf4ef895d42eede41bb5a2f071a501d by Victor Stinner (Joost Lek) in branch 'master': bpo-36688: Adding an implementation of RLock in _dummy_thread (GH-12943) https://github.com/python/cpython/commit/c5905f39bcf4ef895d42eede41bb5a2f071a501d |
|||
| msg345814 - (view) | Author: STINNER Victor (vstinner) * | Date: 2019-06-17 08:12 | |
> Ping. This was marked as a 3.7regression and there is a PR waiting for review. PR 12943 seems reasonable to me. I merged it. > Do we have plans to remove _dummy_thread in 3.8 or 3.9? I created bpo-37312 for Python 3.9. IMHO it's too late for 3.8. |
|||
| msg345819 - (view) | Author: miss-islington (miss-islington) | Date: 2019-06-17 08:28 | |
New changeset 351b0e793e35510e8cbbcbb455a1b9544e808cdd by Miss Islington (bot) in branch '3.7': bpo-36688: Adding an implementation of RLock in _dummy_thread (GH-12943) https://github.com/python/cpython/commit/351b0e793e35510e8cbbcbb455a1b9544e808cdd |
|||
| msg345820 - (view) | Author: miss-islington (miss-islington) | Date: 2019-06-17 08:34 | |
New changeset ad505918a1829e6fa2a48a7665234d60a9377e98 by Miss Islington (bot) in branch '3.8': bpo-36688: Adding an implementation of RLock in _dummy_thread (GH-12943) https://github.com/python/cpython/commit/ad505918a1829e6fa2a48a7665234d60a9377e98 |
|||
| msg345823 - (view) | Author: STINNER Victor (vstinner) * | Date: 2019-06-17 08:44 | |
Thanks Joost Lek for the fix and Karthikeyan Singaravelan for the bug report. It's now fixed in 3.7, 3.8 and master branches. I close the issue. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:59:14 | admin | set | github: 80869 |
| 2019-06-17 08:44:28 | vstinner | set | status: open -> closed resolution: fixed messages: + msg345823 stage: patch review -> resolved |
| 2019-06-17 08:34:30 | miss-islington | set | messages: + msg345820 |
| 2019-06-17 08:28:49 | miss-islington | set | nosy:
+ miss-islington messages: + msg345819 |
| 2019-06-17 08:12:47 | vstinner | set | messages: + msg345814 |
| 2019-06-17 08:10:58 | miss-islington | set | pull_requests: + pull_request13986 |
| 2019-06-17 08:10:52 | miss-islington | set | pull_requests: + pull_request13985 |
| 2019-06-17 08:10:22 | vstinner | set | messages: + msg345813 |
| 2019-06-17 08:08:15 | vstinner | set | nosy:
+ vstinner messages: + msg345812 |
| 2019-06-17 07:31:41 | ned.deily | set | nosy:
+ ned.deily messages:
+ msg345804 |
| 2019-04-24 19:18:25 | python-dev | set | keywords:
+ patch stage: patch review pull_requests: + pull_request12867 |
| 2019-04-22 19:35:15 | brett.cannon | set | keywords:
+ easy, 3.7regression messages:
+ msg340681 |
| 2019-04-21 06:20:08 | xtreak | create | |