Skip to content
Permalink
Browse files

Cache regex in _process_select_response

  • Loading branch information...
carsonip committed Jul 3, 2019
1 parent 46a3ee6 commit d70d322068301efc2670a66ed8f7c976512a717c
Showing with 4 additions and 1 deletion.
  1. +4 −1 imapclient/imapclient.py
@@ -99,6 +99,9 @@
JUNK: ("Junk", "Spam")
}

_RE_SELECT_RESPONSE = re.compile(br'\[(?P<key>[A-Z-]+)( \((?P<data>.*)\))?\]')


class Namespace(tuple):

def __new__(cls, personal, other, shared):
@@ -698,7 +701,7 @@ def _process_select_response(self, resp):
# imaplib doesn't parse these correctly (broken regex) so replace
# with the raw values out of the OK section
for line in untagged.get('OK', []):
match = re.match(br'\[(?P<key>[A-Z-]+)( \((?P<data>.*)\))?\]', line)
match = _RE_SELECT_RESPONSE.match(line)
if match:
key = match.group('key')
if key == b'PERMANENTFLAGS':

0 comments on commit d70d322

Please sign in to comment.
You can’t perform that action at this time.