2to3 main

This commit is contained in:
Rodolfo García Peñas (kix) 2020-08-28 03:32:43 +02:00
parent d5564828ea
commit 6ec6111896
20 changed files with 56 additions and 56 deletions

View File

@ -20,7 +20,7 @@ from sys import exc_info
import six import six
try: try:
from ConfigParser import SafeConfigParser, Error from configparser import SafeConfigParser, Error
except ImportError: # Python3. except ImportError: # Python3.
from configparser import SafeConfigParser, Error from configparser import SafeConfigParser, Error
from offlineimap.localeval import LocalEval from offlineimap.localeval import LocalEval

View File

@ -65,8 +65,8 @@ if bytes != str:
import queue import queue
string_types = str string_types = str
else: else:
import Queue as queue import queue as queue
string_types = basestring string_types = str
select_module = select select_module = select
@ -1871,7 +1871,7 @@ class IMAP4(object):
select.POLLHUP: 'Hang up', select.POLLHUP: 'Hang up',
select.POLLNVAL: 'Invalid request: descriptor not open', select.POLLNVAL: 'Invalid request: descriptor not open',
} }
return ' '.join([PollErrors[s] for s in PollErrors.keys() if (s & state)]) return ' '.join([PollErrors[s] for s in list(PollErrors.keys()) if (s & state)])
if bytes != str: if bytes != str:
line_part = b'' line_part = b''
@ -2698,9 +2698,9 @@ if __name__ == '__main__':
print('Tests failed.') print('Tests failed.')
if not debug: if not debug:
print(''' print(('''
If you would like to see debugging output, If you would like to see debugging output,
try: %s -d5 try: %s -d5
''' % sys.argv[0]) ''' % sys.argv[0]))
raise raise

View File

@ -286,7 +286,7 @@ class BaseFolder(object):
def ismessagelistempty(self): def ismessagelistempty(self):
"""Is the list of messages empty.""" """Is the list of messages empty."""
if len(self.messagelist.keys()) < 1: if len(list(self.messagelist.keys())) < 1:
return True return True
return False return False
@ -1059,14 +1059,14 @@ class BaseFolder(object):
delflaglist[flag] = [] delflaglist[flag] = []
delflaglist[flag].append(uid) delflaglist[flag].append(uid)
for flag, uids in addflaglist.items(): for flag, uids in list(addflaglist.items()):
self.ui.addingflags(uids, flag, dstfolder) self.ui.addingflags(uids, flag, dstfolder)
if self.repository.account.dryrun: if self.repository.account.dryrun:
continue # Don't actually add in a dryrun. continue # Don't actually add in a dryrun.
dstfolder.addmessagesflags(uids, set(flag)) dstfolder.addmessagesflags(uids, set(flag))
statusfolder.addmessagesflags(uids, set(flag)) statusfolder.addmessagesflags(uids, set(flag))
for flag, uids in delflaglist.items(): for flag, uids in list(delflaglist.items()):
self.ui.deletingflags(uids, flag, dstfolder) self.ui.deletingflags(uids, flag, dstfolder)
if self.repository.account.dryrun: if self.repository.account.dryrun:
continue # Don't actually remove in a dryrun. continue # Don't actually remove in a dryrun.

View File

@ -57,11 +57,11 @@ class GmailMaildirFolder(MaildirFolder):
sorted(statusfolder.getmessageuidlist()): sorted(statusfolder.getmessageuidlist()):
return True return True
# Check for flag changes, it's quick on a Maildir. # Check for flag changes, it's quick on a Maildir.
for (uid, message) in self.getmessagelist().items(): for (uid, message) in list(self.getmessagelist().items()):
if message['flags'] != statusfolder.getmessageflags(uid): if message['flags'] != statusfolder.getmessageflags(uid):
return True return True
# check for newer mtimes. it is also fast # check for newer mtimes. it is also fast
for (uid, message) in self.getmessagelist().items(): for (uid, message) in list(self.getmessagelist().items()):
if message['mtime'] > statusfolder.getmessagemtime(uid): if message['mtime'] > statusfolder.getmessagemtime(uid):
return True return True
return False # Nope, nothing changed. return False # Nope, nothing changed.
@ -302,7 +302,7 @@ class GmailMaildirFolder(MaildirFolder):
dellabellist[lb] = [] dellabellist[lb] = []
dellabellist[lb].append(uid) dellabellist[lb].append(uid)
for lb, uids in addlabellist.items(): for lb, uids in list(addlabellist.items()):
# Bail out on CTRL-C or SIGTERM. # Bail out on CTRL-C or SIGTERM.
if offlineimap.accounts.Account.abort_NOW_signal.is_set(): if offlineimap.accounts.Account.abort_NOW_signal.is_set():
break break
@ -313,7 +313,7 @@ class GmailMaildirFolder(MaildirFolder):
dstfolder.addmessageslabels(uids, set([lb])) dstfolder.addmessageslabels(uids, set([lb]))
statusfolder.addmessageslabels(uids, set([lb])) statusfolder.addmessageslabels(uids, set([lb]))
for lb, uids in dellabellist.items(): for lb, uids in list(dellabellist.items()):
# Bail out on CTRL-C or SIGTERM. # Bail out on CTRL-C or SIGTERM.
if offlineimap.accounts.Account.abort_NOW_signal.is_set(): if offlineimap.accounts.Account.abort_NOW_signal.is_set():
break break

View File

@ -177,7 +177,7 @@ class LocalStatusFolder(BaseFolder):
with self.savelock: with self.savelock:
cachefd = open(self.filename + ".tmp", "wt") cachefd = open(self.filename + ".tmp", "wt")
cachefd.write((self.magicline % self.cur_version) + "\n") cachefd.write((self.magicline % self.cur_version) + "\n")
for msg in self.messagelist.values(): for msg in list(self.messagelist.values()):
flags = ''.join(sorted(msg['flags'])) flags = ''.join(sorted(msg['flags']))
labels = ', '.join(sorted(msg['labels'])) labels = ', '.join(sorted(msg['labels']))
cachefd.write("%s|%s|%d|%s\n" % (msg['uid'], flags, msg['mtime'], labels)) cachefd.write("%s|%s|%d|%s\n" % (msg['uid'], flags, msg['mtime'], labels))
@ -237,7 +237,7 @@ class LocalStatusFolder(BaseFolder):
def savemessageslabelsbulk(self, labels): def savemessageslabelsbulk(self, labels):
"""Saves labels from a dictionary in a single database operation.""" """Saves labels from a dictionary in a single database operation."""
for uid, lb in labels.items(): for uid, lb in list(labels.items()):
self.messagelist[uid]['labels'] = lb self.messagelist[uid]['labels'] = lb
self.save() self.save()
@ -257,7 +257,7 @@ class LocalStatusFolder(BaseFolder):
def savemessagesmtimebulk(self, mtimes): def savemessagesmtimebulk(self, mtimes):
"""Saves mtimes from the mtimes dictionary in a single database operation.""" """Saves mtimes from the mtimes dictionary in a single database operation."""
for uid, mt in mtimes.items(): for uid, mt in list(mtimes.items()):
self.messagelist[uid]['mtime'] = mt self.messagelist[uid]['mtime'] = mt
self.save() self.save()

View File

@ -284,7 +284,7 @@ class LocalStatusSQLiteFolder(BaseFolder):
with self._databaseFileLock.getLock(): with self._databaseFileLock.getLock():
data = [] data = []
for uid, msg in self.messagelist.items(): for uid, msg in list(self.messagelist.items()):
mtime = msg['mtime'] mtime = msg['mtime']
flags = ''.join(sorted(msg['flags'])) flags = ''.join(sorted(msg['flags']))
labels = ', '.join(sorted(msg['labels'])) labels = ', '.join(sorted(msg['labels']))
@ -391,9 +391,9 @@ class LocalStatusSQLiteFolder(BaseFolder):
Saves labels from a dictionary in a single database operation. Saves labels from a dictionary in a single database operation.
""" """
data = [(', '.join(sorted(l)), uid) for uid, l in labels.items()] data = [(', '.join(sorted(l)), uid) for uid, l in list(labels.items())]
self.__sql_write('UPDATE status SET labels=? WHERE id=?', data, executemany=True) self.__sql_write('UPDATE status SET labels=? WHERE id=?', data, executemany=True)
for uid, l in labels.items(): for uid, l in list(labels.items()):
self.messagelist[uid]['labels'] = l self.messagelist[uid]['labels'] = l
@ -424,9 +424,9 @@ class LocalStatusSQLiteFolder(BaseFolder):
def savemessagesmtimebulk(self, mtimes): def savemessagesmtimebulk(self, mtimes):
"""Saves mtimes from the mtimes dictionary in a single database operation.""" """Saves mtimes from the mtimes dictionary in a single database operation."""
data = [(mt, uid) for uid, mt in mtimes.items()] data = [(mt, uid) for uid, mt in list(mtimes.items())]
self.__sql_write('UPDATE status SET mtime=? WHERE id=?', data, executemany=True) self.__sql_write('UPDATE status SET mtime=? WHERE id=?', data, executemany=True)
for uid, mt in mtimes.items(): for uid, mt in list(mtimes.items()):
self.messagelist[uid]['mtime'] = mt self.messagelist[uid]['mtime'] = mt

View File

@ -227,7 +227,7 @@ class MaildirFolder(BaseFolder):
positive_uids = [uid for uid in retval if uid > 0] positive_uids = [uid for uid in retval if uid > 0]
if positive_uids: if positive_uids:
min_uid = min(positive_uids) min_uid = min(positive_uids)
for uid in date_excludees.keys(): for uid in list(date_excludees.keys()):
if uid > min_uid: if uid > min_uid:
# This message was originally excluded because of # This message was originally excluded because of
# its date. It is re-included now because we want all # its date. It is re-included now because we want all
@ -245,7 +245,7 @@ class MaildirFolder(BaseFolder):
sorted(statusfolder.getmessageuidlist()): sorted(statusfolder.getmessageuidlist()):
return True return True
# Also check for flag changes, it's quick on a Maildir. # Also check for flag changes, it's quick on a Maildir.
for (uid, message) in self.getmessagelist().items(): for (uid, message) in list(self.getmessagelist().items()):
if message['flags'] != statusfolder.getmessageflags(uid): if message['flags'] != statusfolder.getmessageflags(uid):
return True return True
return False # Nope, nothing changed. return False # Nope, nothing changed.
@ -523,7 +523,7 @@ class MaildirFolder(BaseFolder):
""" """
oldfmd5 = md5(self.name).hexdigest() oldfmd5 = md5(self.name).hexdigest()
msglist = self._scanfolder() msglist = self._scanfolder()
for mkey, mvalue in msglist.items(): for mkey, mvalue in list(msglist.items()):
filename = os.path.join(self.getfullname(), mvalue['filename']) filename = os.path.join(self.getfullname(), mvalue['filename'])
match = re.search("FMD5=([a-fA-F0-9]+)", filename) match = re.search("FMD5=([a-fA-F0-9]+)", filename)
if match is None: if match is None:

View File

@ -110,7 +110,7 @@ class MappedIMAPFolder(IMAPFolder):
except NameError: except NameError:
pass # Windows... pass # Windows...
with open(mapfilenametmp, 'wt') as mapfilefd: with open(mapfilenametmp, 'wt') as mapfilefd:
for (key, value) in self.diskl2r.items(): for (key, value) in list(self.diskl2r.items()):
mapfilefd.write("%d:%d\n"% (key, value)) mapfilefd.write("%d:%d\n"% (key, value))
if self.dofsync(): if self.dofsync():
fsync(mapfilefd) fsync(mapfilefd)
@ -139,7 +139,7 @@ class MappedIMAPFolder(IMAPFolder):
with self.maplock: with self.maplock:
# OK. Now we've got a nice list. First, delete things from the # OK. Now we've got a nice list. First, delete things from the
# summary that have been deleted from the folder. # summary that have been deleted from the folder.
for luid in self.diskl2r.keys(): for luid in list(self.diskl2r.keys()):
if not luid in reallist: if not luid in reallist:
ruid = self.diskl2r[luid] ruid = self.diskl2r[luid]
#XXX: the following KeyError are sightly unexpected. This #XXX: the following KeyError are sightly unexpected. This
@ -166,7 +166,7 @@ class MappedIMAPFolder(IMAPFolder):
self.r2l = self.diskr2l.copy() self.r2l = self.diskr2l.copy()
self.l2r = self.diskl2r.copy() self.l2r = self.diskl2r.copy()
for luid in reallist.keys(): for luid in list(reallist.keys()):
if not luid in self.l2r: if not luid in self.l2r:
ruid = nextneg ruid = nextneg
nextneg -= 1 nextneg -= 1
@ -192,7 +192,7 @@ class MappedIMAPFolder(IMAPFolder):
# This implementation overrides the one in BaseFolder, as it is # This implementation overrides the one in BaseFolder, as it is
# much more efficient for the mapped case. # much more efficient for the mapped case.
return self.r2l.keys() return list(self.r2l.keys())
# Interface from BaseFolder # Interface from BaseFolder
def getmessagecount(self): def getmessagecount(self):

View File

@ -220,7 +220,7 @@ class WrappedIMAP4_SSL(UsefulIMAPMixIn, IMAP4_SSL):
"does not match configured fingerprint(s) %s. " "does not match configured fingerprint(s) %s. "
"Please verify and set 'cert_fingerprint' accordingly " "Please verify and set 'cert_fingerprint' accordingly "
"if not set yet."% "if not set yet."%
(zip([hash.__name__ for hash in hashes], server_fingerprints), host, self._fingerprint), (list(zip([hash.__name__ for hash in hashes], server_fingerprints)), host, self._fingerprint),
OfflineImapError.ERROR.REPO) OfflineImapError.ERROR.REPO)

View File

@ -19,7 +19,7 @@ import datetime
import hmac import hmac
import socket import socket
import json import json
import urllib import urllib.request, urllib.parse, urllib.error
import time import time
import errno import errno
import socket import socket
@ -247,8 +247,8 @@ class IMAPServer(object):
original_socket = socket.socket original_socket = socket.socket
socket.socket = self.authproxied_socket socket.socket = self.authproxied_socket
try: try:
response = urllib.urlopen( response = urllib.request.urlopen(
self.oauth2_request_url, urllib.urlencode(params)).read() self.oauth2_request_url, urllib.parse.urlencode(params)).read()
except Exception as e: except Exception as e:
try: try:
msg = "%s (configuration is: %s)"% (e, str(params)) msg = "%s (configuration is: %s)"% (e, str(params))
@ -260,11 +260,11 @@ class IMAPServer(object):
resp = json.loads(response) resp = json.loads(response)
self.ui.debug('imap', 'xoauth2handler: response "%s"'% resp) self.ui.debug('imap', 'xoauth2handler: response "%s"'% resp)
if u'error' in resp: if 'error' in resp:
raise OfflineImapError("xoauth2handler got: %s"% resp, raise OfflineImapError("xoauth2handler got: %s"% resp,
OfflineImapError.ERROR.REPO) OfflineImapError.ERROR.REPO)
self.oauth2_access_token = resp['access_token'] self.oauth2_access_token = resp['access_token']
if u'expires_in' in resp: if 'expires_in' in resp:
self.oauth2_access_token_expires_at = now + datetime.timedelta( self.oauth2_access_token_expires_at = now + datetime.timedelta(
seconds=resp['expires_in']/2 seconds=resp['expires_in']/2
) )
@ -444,7 +444,7 @@ class IMAPServer(object):
continue continue
tried_to_authn = True tried_to_authn = True
self.ui.debug('imap', u'Attempting ' self.ui.debug('imap', 'Attempting '
'%s authentication'% m) '%s authentication'% m)
try: try:
if func(imapobj): if func(imapobj):
@ -461,7 +461,7 @@ class IMAPServer(object):
if not tried_to_authn: if not tried_to_authn:
methods = ", ".join([x[5:] for x in methods = ", ".join([x[5:] for x in
[x for x in imapobj.capabilities if x[0:5] == "AUTH="]]) [x for x in imapobj.capabilities if x[0:5] == "AUTH="]])
raise OfflineImapError(u"Repository %s: no supported " raise OfflineImapError("Repository %s: no supported "
"authentication mechanisms found; configured %s, " "authentication mechanisms found; configured %s, "
"server advertises %s"% (self.repos, "server advertises %s"% (self.repos,
", ".join(self.authmechs), methods), ", ".join(self.authmechs), methods),

View File

@ -416,7 +416,7 @@ def encoder(s):
# decoding # decoding
def modified_unbase64(s): def modified_unbase64(s):
b = binascii.a2b_base64(s.replace(',', '/') + '===') b = binascii.a2b_base64(s.replace(',', '/') + '===')
return unicode(b, 'utf-16be') return str(b, 'utf-16be')
def decoder(s): def decoder(s):
r = [] r = []

View File

@ -191,9 +191,9 @@ class OfflineImap(object):
glob.set_options(options) glob.set_options(options)
if options.version: if options.version:
print("offlineimap v%s, %s"% ( print(("offlineimap v%s, %s"% (
offlineimap.__version__, self.get_env_info()) offlineimap.__version__, self.get_env_info())
) ))
sys.exit(0) sys.exit(0)
# Read in configuration file. # Read in configuration file.
@ -255,7 +255,7 @@ class OfflineImap(object):
ui_type = ui_type.split('.')[-1] ui_type = ui_type.split('.')[-1]
# TODO, make use of chosen ui for logging # TODO, make use of chosen ui for logging
logging.warning('Using old interface name, consider using one ' logging.warning('Using old interface name, consider using one '
'of %s'% ', '.join(UI_LIST.keys())) 'of %s'% ', '.join(list(UI_LIST.keys())))
if options.diagnostics: if options.diagnostics:
ui_type = 'ttyui' # Enforce this UI for --info. ui_type = 'ttyui' # Enforce this UI for --info.
@ -269,7 +269,7 @@ class OfflineImap(object):
self.ui = UI_LIST[ui_type.lower()](config) self.ui = UI_LIST[ui_type.lower()](config)
except KeyError: except KeyError:
logging.error("UI '%s' does not exist, choose one of: %s"% logging.error("UI '%s' does not exist, choose one of: %s"%
(ui_type, ', '.join(UI_LIST.keys()))) (ui_type, ', '.join(list(UI_LIST.keys()))))
sys.exit(1) sys.exit(1)
setglobalui(self.ui) setglobalui(self.ui)
@ -363,10 +363,10 @@ class OfflineImap(object):
d = collections.defaultdict(lambda: 0) d = collections.defaultdict(lambda: 0)
for v in l: for v in l:
d[tuple(v)] += 1 d[tuple(v)] += 1
return list((k, v) for k, v in d.items()) return list((k, v) for k, v in list(d.items()))
stack_displays = [] stack_displays = []
for threadId, stack in sys._current_frames().items(): for threadId, stack in list(sys._current_frames().items()):
stack_display = [] stack_display = []
for filename, lineno, name, line in traceback.extract_stack(stack): for filename, lineno, name, line in traceback.extract_stack(stack):
stack_display.append(' File: "%s", line %d, in %s' stack_display.append(' File: "%s", line %d, in %s'
@ -387,7 +387,7 @@ class OfflineImap(object):
self.ui.debug('thread', msg % (times, '\n'.join(stack[- (context * 2):]))) self.ui.debug('thread', msg % (times, '\n'.join(stack[- (context * 2):])))
self.ui.debug('thread', "Dumped a total of %d Threads." % self.ui.debug('thread', "Dumped a total of %d Threads." %
len(sys._current_frames().keys())) len(list(sys._current_frames().keys())))
def _get_activeaccounts(self, options): def _get_activeaccounts(self, options):
activeaccounts = [] activeaccounts = []

View File

@ -23,7 +23,7 @@ from threading import Lock
from os import listdir, makedirs, path, unlink from os import listdir, makedirs, path, unlink
from sys import exc_info from sys import exc_info
try: try:
from ConfigParser import NoSectionError from configparser import NoSectionError
except ImportError: # Py3. except ImportError: # Py3.
from configparser import NoSectionError from configparser import NoSectionError

View File

@ -197,7 +197,7 @@ class BaseRepository(CustomConfig.ConfigHelperMixin):
local_hash[folder.getname()] = folder local_hash[folder.getname()] = folder
# Create new folders from remote to local. # Create new folders from remote to local.
for remote_name, remote_folder in remote_hash.items(): for remote_name, remote_folder in list(remote_hash.items()):
# Don't create on local_repo, if it is readonly. # Don't create on local_repo, if it is readonly.
if not local_repo.should_create_folders(): if not local_repo.should_create_folders():
break break
@ -205,7 +205,7 @@ class BaseRepository(CustomConfig.ConfigHelperMixin):
# Apply remote nametrans and fix serparator. # Apply remote nametrans and fix serparator.
local_name = remote_folder.getvisiblename().replace( local_name = remote_folder.getvisiblename().replace(
remote_repo.getsep(), local_repo.getsep()) remote_repo.getsep(), local_repo.getsep())
if remote_folder.sync_this and not local_name in local_hash.keys(): if remote_folder.sync_this and not local_name in list(local_hash.keys()):
try: try:
local_repo.makefolder(local_name) local_repo.makefolder(local_name)
# Need to refresh list. # Need to refresh list.
@ -219,7 +219,7 @@ class BaseRepository(CustomConfig.ConfigHelperMixin):
local_repo.getsep(), status_repo.getsep())) local_repo.getsep(), status_repo.getsep()))
# Create new folders from local to remote. # Create new folders from local to remote.
for local_name, local_folder in local_hash.items(): for local_name, local_folder in list(local_hash.items()):
if not remote_repo.should_create_folders(): if not remote_repo.should_create_folders():
# Don't create missing folder on readonly repo. # Don't create missing folder on readonly repo.
break break
@ -227,7 +227,7 @@ class BaseRepository(CustomConfig.ConfigHelperMixin):
# Apply reverse nametrans and fix serparator. # Apply reverse nametrans and fix serparator.
remote_name = local_folder.getvisiblename().replace( remote_name = local_folder.getvisiblename().replace(
local_repo.getsep(), remote_repo.getsep()) local_repo.getsep(), remote_repo.getsep())
if local_folder.sync_this and not remote_name in remote_hash.keys(): if local_folder.sync_this and not remote_name in list(remote_hash.keys()):
# Would the remote filter out the new folder name? In this case # Would the remote filter out the new folder name? In this case
# don't create it. # don't create it.
if not remote_repo.should_sync_folder(remote_name): if not remote_repo.should_sync_folder(remote_name):

View File

@ -57,13 +57,13 @@ class LocalStatusRepository(BaseRepository):
return self.LocalStatusFolderClass(foldername, self) # Instanciate. return self.LocalStatusFolderClass(foldername, self) # Instanciate.
def setup_backend(self, backend): def setup_backend(self, backend):
if backend in self.backends.keys(): if backend in list(self.backends.keys()):
self._backend = backend self._backend = backend
self.root = self.backends[backend]['root'] self.root = self.backends[backend]['root']
self.LocalStatusFolderClass = self.backends[backend]['class'] self.LocalStatusFolderClass = self.backends[backend]['class']
def import_other_backend(self, folder): def import_other_backend(self, folder):
for bk, dic in self.backends.items(): for bk, dic in list(self.backends.items()):
# Skip folder's own type. # Skip folder's own type.
if dic['class'] == type(folder): if dic['class'] == type(folder):
continue continue

View File

@ -20,7 +20,7 @@ from sys import exc_info
try: try:
from configparser import NoSectionError from configparser import NoSectionError
except ImportError: #python2 except ImportError: #python2
from ConfigParser import NoSectionError from configparser import NoSectionError
from offlineimap.repository.IMAP import IMAPRepository, MappedIMAPRepository from offlineimap.repository.IMAP import IMAPRepository, MappedIMAPRepository
from offlineimap.repository.Gmail import GmailRepository from offlineimap.repository.Gmail import GmailRepository

View File

@ -17,7 +17,7 @@
from threading import Lock, Thread, BoundedSemaphore, currentThread from threading import Lock, Thread, BoundedSemaphore, currentThread
try: try:
from Queue import Queue, Empty from queue import Queue, Empty
except ImportError: # python3 except ImportError: # python3
from queue import Queue, Empty from queue import Queue, Empty
import traceback import traceback

View File

@ -14,7 +14,7 @@
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
try: try:
from urllib import urlencode from urllib.parse import urlencode
except ImportError: # python3 except ImportError: # python3
from urllib.parse import urlencode from urllib.parse import urlencode
import sys import sys

View File

@ -23,7 +23,7 @@ import sys
import traceback import traceback
import threading import threading
try: try:
from Queue import Queue from queue import Queue
except ImportError: # python3 except ImportError: # python3
from queue import Queue from queue import Queue
from collections import deque from collections import deque

View File

@ -13,7 +13,7 @@ def dump(out):
for th in threading.enumerate(): for th in threading.enumerate():
id2name[th.ident] = th.name id2name[th.ident] = th.name
n = 0 n = 0
for i, stack in sys._current_frames().items(): for i, stack in list(sys._current_frames().items()):
out.write ("\n# Thread #%d (id=%d), %s\n" % \ out.write ("\n# Thread #%d (id=%d), %s\n" % \
(n, i, id2name[i])) (n, i, id2name[i]))
n = n + 1 n = n + 1