offlineimap icon indicating copy to clipboard operation
offlineimap copied to clipboard

syntax warnings about invalid escape sequences

Open dnebauer opened this issue 7 months ago • 0 comments

Running offlineimap recently began showing the following warnings:

/usr/lib/python3/dist-packages/imaplib2.py:2472: SyntaxWarning: invalid escape sequence '\D'
  ('store', ('1', 'FLAGS', '(\Deleted)')),
/usr/lib/python3/dist-packages/imaplib2.py:2577: SyntaxWarning: invalid escape sequence '\D'
  run('uid', ('STORE', uid[-1], 'FLAGS', '(\Deleted)'))
/usr/lib/python3/dist-packages/imaplib2.py:2591: SyntaxWarning: invalid escape sequence '\S'
  run('store', (num, '-FLAGS', '(\Seen)'), cb=False),
/usr/lib/python3/dist-packages/imaplib2.py:2594: SyntaxWarning: invalid escape sequence '\D'
  run('uid', ('STORE', num, 'FLAGS', '(\Deleted)'))

The corresponding lines from imaplib2.py are

2472:

    ('store', ('1', 'FLAGS', '(\Deleted)')),

2577:

            run('uid', ('STORE', uid[-1], 'FLAGS', '(\Deleted)'))

2591:

            run('store', (num, '-FLAGS', '(\Seen)'), cb=False),

2594:

            run('uid', ('STORE', num, 'FLAGS', '(\Deleted)'))

It seems using invalid escape sequences in string literals has been deprecated since Python 3.6, following which it would generate a DeprecationWarning, and deprecation warnings may not be displayed by default.

With Python 3.12 this use of invalid escape sequences was upgraded to a SyntaxWarning, which is displayed by default.

Aside from making the running of offlineimap "noisy", this change would not matter except for claims that the use of invalid escape sequences in string literals is planned to eventually become a hard SyntaxError.

dnebauer avatar Jul 14 '24 00:07 dnebauer