@@ -192,6 +192,19 @@ In general, pass arguments unquoted and let the module quote them as needed.
192192An argument that is already enclosed in double quotes is left unchanged,
193193so that code which quotes arguments itself keeps working.
194194
195+ Mailbox names are encoded as modified UTF-7 (:rfc: `3501 `, section 5.1.3),
196+ so a mailbox name containing non-ASCII characters can be passed as an
197+ ordinary :class: `str `.
198+ A :class: `str ` that is already valid modified UTF-7 is left unchanged,
199+ so that a name obtained from :meth: `~IMAP4.list ` (raw ``bytes `` decoded to
200+ text) round-trips; pass :class: `bytes ` to send the exact bytes with no
201+ encoding.
202+ When ``UTF8=ACCEPT `` is enabled (see :meth: `~IMAP4.enable `), mailbox names
203+ are sent as UTF-8 instead.
204+
205+ .. versionchanged :: next
206+ Non-ASCII mailbox names are automatically encoded as modified UTF-7.
207+
195208Most commands return a tuple: ``(type, [data, ...]) `` where *type * is usually
196209``'OK' `` or ``'NO' ``, and *data * is either the text from the command response,
197210or mandated results from the command. Each *data * is either a ``bytes ``, or a
@@ -260,10 +273,16 @@ An :class:`IMAP4` instance has the following methods:
260273 mailbox. This is the recommended command before ``LOGOUT ``.
261274
262275
263- .. method :: IMAP4.copy(message_set, new_mailbox)
276+ .. method :: IMAP4.copy(message_set, new_mailbox, *, uid=False )
264277
265278 Copy *message_set * messages onto end of *new_mailbox *.
266279
280+ If *uid * is true, *message_set * is a set of UIDs and the ``UID COPY ``
281+ command is used instead of ``COPY ``.
282+
283+ .. versionchanged :: next
284+ Added the *uid * parameter.
285+
267286
268287.. method :: IMAP4.create(mailbox)
269288
@@ -290,19 +309,33 @@ An :class:`IMAP4` instance has the following methods:
290309 The :meth: `enable ` method itself, and :RFC: `6855 ` support.
291310
292311
293- .. method :: IMAP4.expunge()
312+ .. method :: IMAP4.expunge(message_set=None, *, uid=False )
294313
295314 Permanently remove deleted items from selected mailbox. Generates an ``EXPUNGE ``
296315 response for each deleted message. Returned data contains a list of ``EXPUNGE ``
297316 message numbers in order received.
298317
318+ If *uid * is true, the ``UID EXPUNGE `` command (:rfc: `4315 `) is used to remove
319+ only the messages that both are marked as deleted and have a UID in
320+ *message_set *. *message_set * is required in this case, and must be omitted
321+ otherwise.
322+
323+ .. versionchanged :: next
324+ Added the *message_set * and *uid * parameters.
325+
299326
300- .. method :: IMAP4.fetch(message_set, message_parts)
327+ .. method :: IMAP4.fetch(message_set, message_parts, *, uid=False )
301328
302329 Fetch (parts of) messages. *message_parts * should be a string of message part
303330 names enclosed within parentheses, eg: ``"(UID BODY[TEXT])" ``. Returned data
304331 are tuples of message part envelope and data.
305332
333+ If *uid * is true, *message_set * is a set of UIDs and the message numbers in
334+ the response are UIDs (``UID FETCH ``).
335+
336+ .. versionchanged :: next
337+ Added the *uid * parameter.
338+
306339
307340.. method :: IMAP4.getacl(mailbox)
308341
@@ -482,12 +515,15 @@ An :class:`IMAP4` instance has the following methods:
482515 Returned data are tuples of message part envelope and data.
483516
484517
485- .. method :: IMAP4.move(message_set, new_mailbox)
518+ .. method :: IMAP4.move(message_set, new_mailbox, *, uid=False )
486519
487520 Move *message_set * messages onto end of *new_mailbox *.
488521
489522 The server must support the ``MOVE `` capability (:rfc: `6851 `).
490523
524+ If *uid * is true, *message_set * is a set of UIDs and the ``UID MOVE ``
525+ command is used instead of ``MOVE ``.
526+
491527 .. versionadded :: next
492528
493529
@@ -562,7 +598,7 @@ An :class:`IMAP4` instance has the following methods:
562598 code, instead of the usual type.
563599
564600
565- .. method :: IMAP4.search(charset, criterion[, ...])
601+ .. method :: IMAP4.search(charset, criterion[, ...], *, uid=False )
566602
567603 Search mailbox for matching messages. *charset * may be ``None ``, in which case
568604 no ``CHARSET `` will be specified in the request to the server. The IMAP
@@ -571,6 +607,9 @@ An :class:`IMAP4` instance has the following methods:
571607 the ``UTF8=ACCEPT `` capability was enabled using the :meth: `enable `
572608 command.
573609
610+ If *uid * is true, the message numbers in the response are UIDs
611+ (``UID SEARCH ``).
612+
574613 Example::
575614
576615 # M is a connected IMAP4 instance...
@@ -579,6 +618,9 @@ An :class:`IMAP4` instance has the following methods:
579618 # or:
580619 typ, msgnums = M.search(None, '(FROM "LDJ")')
581620
621+ .. versionchanged :: next
622+ Added the *uid * parameter.
623+
582624
583625.. method :: IMAP4.select(mailbox='INBOX', readonly=False)
584626
@@ -623,7 +665,7 @@ An :class:`IMAP4` instance has the following methods:
623665 Returns socket instance used to connect to server.
624666
625667
626- .. method :: IMAP4.sort(sort_criteria, charset, search_criterion[, ...])
668+ .. method :: IMAP4.sort(sort_criteria, charset, search_criterion[, ...], *, uid=False )
627669
628670 The ``sort `` command is a variant of ``search `` with sorting semantics for the
629671 results. Returned data contains a space separated list of matching message
@@ -638,8 +680,13 @@ An :class:`IMAP4` instance has the following methods:
638680 the interpretation of strings in the searching criteria. It then returns the
639681 numbers of matching messages.
640682
683+ If *uid * is true, the message numbers in the response are UIDs (``UID SORT ``).
684+
641685 This is an ``IMAP4rev1 `` extension command.
642686
687+ .. versionchanged :: next
688+ Added the *uid * parameter.
689+
643690
644691.. method :: IMAP4.starttls(ssl_context=None)
645692
@@ -668,12 +715,15 @@ An :class:`IMAP4` instance has the following methods:
668715 Request named status conditions for *mailbox *.
669716
670717
671- .. method :: IMAP4.store(message_set, command, flag_list)
718+ .. method :: IMAP4.store(message_set, command, flag_list, *, uid=False )
672719
673720 Alters flag dispositions for messages in mailbox. *command * is specified by
674721 section 6.4.6 of :rfc: `3501 ` as being one of "FLAGS", "+FLAGS", or "-FLAGS",
675722 optionally with a suffix of ".SILENT".
676723
724+ If *uid * is true, *message_set * is a set of UIDs and the ``UID STORE ``
725+ command is used instead of ``STORE ``.
726+
677727 For example, to set the delete flag on all messages::
678728
679729 typ, data = M.search(None, 'ALL')
@@ -693,12 +743,15 @@ An :class:`IMAP4` instance has the following methods:
693743 Python 3.6, handles them if they are sent from the server, since this
694744 improves real-world compatibility.
695745
746+ .. versionchanged :: next
747+ Added the *uid * parameter.
748+
696749.. method :: IMAP4.subscribe(mailbox)
697750
698751 Subscribe to new mailbox.
699752
700753
701- .. method :: IMAP4.thread(threading_algorithm, charset, search_criterion[, ...])
754+ .. method :: IMAP4.thread(threading_algorithm, charset, search_criterion[, ...], *, uid=False )
702755
703756 The ``thread `` command is a variant of ``search `` with threading semantics for
704757 the results. Returned data contains a space separated list of thread members.
@@ -716,8 +769,14 @@ An :class:`IMAP4` instance has the following methods:
716769 returns the matching messages threaded according to the specified threading
717770 algorithm.
718771
772+ If *uid * is true, the message numbers in the response are UIDs
773+ (``UID THREAD ``).
774+
719775 This is an ``IMAP4rev1 `` extension command.
720776
777+ .. versionchanged :: next
778+ Added the *uid * parameter.
779+
721780
722781.. method :: IMAP4.uid(command, arg[, ...])
723782
0 commit comments