OfflineIMAP / offlineimap

Read/sync your IMAP mailboxes (python2) [LEGACY: move to offlineimap3]
http://www.offlineimap.org
Other
1.78k stars 360 forks source link

syntax warnings about invalid escape sequences #738

Closed dnebauer closed 2 weeks ago

dnebauer commented 4 months ago

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.

nicolas33 commented 2 weeks ago

Please, consider moving to https://github.com/OfflineIMAP/offlineimap3.

dnebauer commented 2 weeks ago

I already did that some time ago. I'll close this since I can no longer track whether this bug is fixed or not.