Skip to content

Commit d4ce21e

Browse files
committed
Move bpython._py3compat.is_main_thread to bpython.curtsiesfrontend.code
1 parent e858ed1 commit d4ce21e

File tree

3 files changed

+8
-16
lines changed

3 files changed

+8
-16
lines changed

bpython/_py3compat.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232

3333

3434
import sys
35-
import threading
3635

3736
py3 = sys.version_info[0] == 3
3837

@@ -53,15 +52,3 @@ def try_decode(s, encoding):
5352
except UnicodeDecodeError:
5453
return None
5554
return s
56-
57-
58-
if py3:
59-
60-
def is_main_thread():
61-
return threading.main_thread() == threading.current_thread()
62-
63-
64-
else:
65-
66-
def is_main_thread():
67-
return isinstance(threading.current_thread(), threading._MainThread)

bpython/curtsiesfrontend/coderunner.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,18 @@
1414
import signal
1515
import greenlet
1616
import logging
17+
import threading
1718

18-
from bpython._py3compat import py3, is_main_thread
19+
from bpython._py3compat import py3
1920
from bpython.config import getpreferredencoding
2021

2122
logger = logging.getLogger(__name__)
2223

2324

25+
def is_main_thread():
26+
return threading.main_thread() == threading.current_thread()
27+
28+
2429
class SigintHappened(object):
2530
"""If this class is returned, a SIGINT happened while the main greenlet"""
2631

bpython/curtsiesfrontend/repl.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@
3636
from bpython.formatter import BPythonFormatter
3737
from bpython import autocomplete
3838
from bpython.translations import _
39-
from bpython._py3compat import py3, is_main_thread
39+
from bpython._py3compat import py3
4040
from bpython.pager import get_pager_command
4141

4242
from bpython.curtsiesfrontend import replpainter as paint
4343
from bpython.curtsiesfrontend import sitefix
44-
from bpython.curtsiesfrontend.coderunner import CodeRunner, FakeOutput
44+
from bpython.curtsiesfrontend.coderunner import CodeRunner, FakeOutput, is_main_thread
4545
from bpython.curtsiesfrontend.filewatch import ModuleChangedEventHandler
4646
from bpython.curtsiesfrontend.interaction import StatusBar
4747
from bpython.curtsiesfrontend.manual_readline import edit_keys

0 commit comments

Comments
 (0)