invasive patch to drop support for Python 2.5, part 01/03
Stephen Gildea <[email protected]> Thu, 04 Nov 2021 01:35:52 -0700
| Newsgroups | gmane.mail.getmail.user |
|---|---|
| Message-ID | <1687651.1636014952@pental> |
getmail currently supports Python 2.3.3 through 2.7, an impressive compatibility stretch that covers 16 years of Python, from 2003 to 2019. To move getmail compatibility forward to include the year 2021, we are going to have to also move up the oldest date. The attached patch starts that process. It changes almost all occurrences of the "except" syntax to that required by Python 3 and allowed since Python 2.6. This moves up the oldest Python supported by getmail to 2.6, released in 2008. This patch also removes all checks for the Python version, because they no longer work. The Python 3 syntax can't even be read by Python 2.5, so the program wouldn't get as far as displaying the version error. While this loses five years of compatibility, it is still compatible with all Python versions released in the last 13 years and all supported for the last 10 years. (Python 2.5 security support ended in 2011.) I think this is a reasonable compatibility compromise. This patch is rather invasive, touching over 100 statements across all files. Getting it out of the way seems a good place to start. Future patches moving toward Python 3 should be less invasive. I have broken the patch into three parts. The first part, attached, changes the claimed Python compatibility from 2.3.3 to 2.6. The second and third parts enforce that by using the new syntax for "except" clauses. < Stephen --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
01-getmail-for-python-2.6.patch
(text/x-diff, 13.8 KB)
diff -ur getmail-5.16/docs/CHANGELOG getmail-5.16-for-python-2.6/docs/CHANGELOG
--- getmail-5.16/docs/CHANGELOG 2021-10-31 09:13:24.000000000 -0700
+++ getmail-5.16-for-python-2.6/docs/CHANGELOG 2021-11-01 23:19:59.761845804 -0700
@@ -1,3 +1,8 @@
+Version 5.17
+1 November 2021 or later
+ -drop support for Python 2.3, 2.4, and 2.5.
+ (Python 2.5 security support ended in 2011.)
+
Version 5.16
31 October 2021
-add new use_netrc and netrc_file configuration options to support
diff -ur getmail-5.16/README getmail-5.16-for-python-2.6/README
--- getmail-5.16/README 2021-10-31 14:39:46.000000000 -0700
+++ getmail-5.16-for-python-2.6/README 2021-11-01 23:11:23.514303652 -0700
@@ -7,7 +7,7 @@
getmail is licensed for use under the GNU General Public License version 2
(only). See docs/COPYING for specific terms and distribution information.
-getmail version 5 requires Python version 2.3.3 or later. You can have
+getmail version 5 requires Python version 2.6 or 2.7. You can have
several installed versions of Python peacefully co-existing, see
python.org for details.
diff -ur getmail-5.16/docs/configuration.html getmail-5.16-for-python-2.6/docs/configuration.html
--- getmail-5.16/docs/configuration.html 2021-10-31 16:27:26.000000000 -0700
+++ getmail-5.16-for-python-2.6/docs/configuration.html 2021-11-01 23:23:11.507151684 -0700
@@ -719,11 +719,7 @@
the specific SSL cipher used during the connection.
</p>
<p>
- <strong>Note: using these features, including server certificate validation,
- requires using Python 2.6 or Python 2.7 or higher with getmail.</strong>
- If you use an earlier version of Python, these features will not work, and
- no server certificate validation will be performed.
- Also note that these features are not currently implemented for SPDS
+ Note that these features are not currently implemented for SPDS
retrievers; I would be interested in hearing from SPDS users who desire
these features.
</p>
@@ -734,7 +730,6 @@
— advanced option to perform validation of the server's SSL
certificate. Specify the path to a PEM-formatted list of 1 or more
valid and trusted root certification authority (CA) certificates.
- <strong>Note: this option is only available with Python 2.6 or higher.</strong>
<br />
To find out which root CA is used to sign the chain of certificates for
a given server, you can run
@@ -781,7 +776,6 @@
most users should not specify this option at all. Using this option
without knowing what you are doing can reduce the effectiveness of
your encrypted connection.
- <strong>Note: this option is only available with Python 2.6 or higher.</strong>
Note: see the <a href="faq.html#faq-notabug-gmail-tls-sni">FAQ for details
on how to work around Gmail connection problems with OpenSSL v.1.1.1 and later</a>.
</li>
@@ -794,7 +788,6 @@
in the list of allowed fingerprints; if it is not, getmail will abort
the connection. Getmail will log the fingerprint of the server's certificate
if you supply the <span class="file">--fingerprint</span> commandline option.
- <strong>Note: this option is only available with Python 2.6 or higher.</strong>
</li>
<li>
ssl_cert_hostname
diff -ur getmail-5.16/docs/documentation.html getmail-5.16-for-python-2.6/docs/documentation.html
--- getmail-5.16/docs/documentation.html 2021-10-31 16:27:26.000000000 -0700
+++ getmail-5.16-for-python-2.6/docs/documentation.html 2021-11-01 23:06:30.608249369 -0700
@@ -428,27 +428,7 @@
<p>
getmail version 5 requires
<a href="http://www.python.org/">Python</a>
- version 2.3.3 or later. If you have only an earlier version of Python
- available, you can install the latest version without disturbing your
- current version, or use getmail version 3, which requires only Python
- version 1.5.2 or later.
-</p>
-<p>
- At the time of this writing, the current stable version of Python is
- 2.3.4. You can download that version from the page at
- <a href="http://www.python.org/2.3.4/">http://www.python.org/2.3.4/</a>
- . Binary packages are available for RPM-based
- Linux systems, or building Python from source is typically as easy
- as unpacking the source tarball, and running the following commands:
-</p>
-<pre class="example">
-./configure
-make
-make install
-</pre>
-<p>
- Since the above was written, Python 2.4 has been released. getmail 5
- will work with that version of Python as well.
+ version 2.6 or 2.7.
</p>
<p>
getmail 5 also requires that servers uniquely identify the messages
diff -ur getmail-5.16/docs/faq.html getmail-5.16-for-python-2.6/docs/faq.html
--- getmail-5.16/docs/faq.html 2021-10-31 16:27:26.000000000 -0700
+++ getmail-5.16-for-python-2.6/docs/faq.html 2021-11-01 23:25:04.031916336 -0700
@@ -192,8 +192,6 @@
<li>
<ul>
<li><a href="faq.html#faq-notabug-gmail-bug">getmail doesn't download all my mail from Gmail …</a></li>
- <li><a href="faq.html#faq-notabug-futurewarning">FutureWarning: %u/%o/%x/%X of negative int will return a signed string in Python 2.4 and up</a></li>
- <li><a href="faq.html#faq-notabug-fsync">AttributeError: 'module' object has no attribute 'fsync'</a></li>
<li><a href="faq.html#faq-notabug-brokenpopserver">operation error (SimplePOP3Retriever: [...] does not uniquely identify messages [...] see documentation or use BrokenUIDLPOP3Retriever instead</a></li>
<li><a href="faq.html#faq-notabug-osx-realloc">MemoryError on OS X</a></li>
<li><a href="faq.html#faq-notabug-memory">MemoryError when using IMAP</a></li>
@@ -1666,31 +1664,6 @@
provided their spam filters never give false positive results (ha!).
</p>
-<h3 id="faq-notabug-futurewarning">FutureWarning: %u/%o/%x/%X of negative int will return a signed string in Python 2.4 and up</h3>
-<p>
- Various people have reported this "bug" in getmail, where they
- see the following warning when getmail is run:
-</p>
-<pre class="example">
-/usr/lib/python2.3/optparse.py:668: FutureWarning: %u/%o/%x/%X of negative int will return a signed string in Python 2.4 and up
- return ("<%s at 0x%x: %r>"
-</pre>
-<p>
- This warning is a bug in Python 2.3.4's
- <span class="file">optparse.py</span>
- module, not in getmail. Feel free to report it to the Python team if the
- most recent release of Python hasn't fixed it. I reported it in June, 2004.
-</p>
-
-<h3 id="faq-notabug-fsync">AttributeError: 'module' object has no attribute 'fsync'</h3>
-<p>
- Various people have reported this "bug" in getmail — it's
- actually a bug in some versions of Python 2.3.X. It was fixed in Python
- version 2.3.3. getmail 5 detects problematic versions of Python and refuses
- to run, but you can still encounter this problem with getmail version 3
- if you try to run it with a broken Python version.
-</p>
-
<h3 id="faq-notabug-brokenpopserver">operation error (SimplePOP3Retriever: [...] does not uniquely identify messages [...] see documentation or use BrokenUIDLPOP3Retriever instead</h3>
<p>
The server you're trying to use does not properly uniquely identify messages
@@ -1756,13 +1729,13 @@
... which then end with <span class="sample">MemoryError</span>,
you've run into
<a href="http://bugs.python.org/issue1389051">a bug in Python's IMAP library</a>.
- It's fixed in the most recent versions of Python 2.5 and 2.6. This bug can
+ It's fixed in the most recent version of Python 2.6. This bug can
cause getmail to grow to a huge size, vastly out of proportion to the size
of the message it's retrieving, at which point Python may fail or be killed
when the system runs out of memory.
</p>
<p>
- Upgrade your Python installation to the newest Python 2.5 or 2.6 version to
+ Upgrade your Python installation to Python 2.7 or the newest Python 2.6 version to
fix the problem, or use POP3 instead of IMAP to work around it.
</p>
diff -ur getmail-5.16/docs/troubleshooting.html getmail-5.16-for-python-2.6/docs/troubleshooting.html
--- getmail-5.16/docs/troubleshooting.html 2021-10-31 16:27:26.000000000 -0700
+++ getmail-5.16-for-python-2.6/docs/troubleshooting.html 2021-11-01 23:25:39.800157622 -0700
@@ -89,7 +89,6 @@
<li><a href="troubleshooting.html#error-messages">Error messages</a></li>
<li>
<ul>
- <li><a href="troubleshooting.html#errmsg-pyversion">ImportError: getmail version 5 requires Python version 2.3.3 or later</a></li>
<li><a href="troubleshooting.html#errmsg-config">Configuration error: …</a></li>
<li>
<ul>
@@ -204,15 +203,6 @@
</p>
<!-- ********************************************************************** -->
-<h3 id="errmsg-pyversion" class="errmsg">ImportError: getmail version 5 requires Python version 2.3.3 or later</h3>
-<p>
- You tried to run getmail 5 with a version of Python prior to Python 2.3.3.
- This is unsupported. If you cannot install a newer Python alongside your
- current version, please use getmail version 3, which supports Python 1.5.2
- and later.
-</p>
-
-<!-- ********************************************************************** -->
<h3 id="errmsg-config" class="errmsg">Configuration error: …</h3>
<p>
getmail detected an error in your configuration. Check your getmail rc
@@ -420,10 +410,7 @@
<p>
If you are using IMAP and run into this problem retrieving messages that
aren't hundreds of megabytes in size, you can almost certainly fix it by
- upgrading your Python installation to the latest 2.5.x or 2.6.x release.
- Note that if you switch from Python 2.5.x to Python 2.6.x, you'll need to
- re-install getmail with <span class="file">python setup.py install</span>
- from the getmail source directory.
+ upgrading your Python installation to 2.7 or the latest 2.6.x release.
</p>
<!-- ********************************************************************** -->
diff -ur getmail-5.16/getmail getmail-5.16-for-python-2.6/getmail
--- getmail-5.16/getmail 2021-10-31 15:16:25.000000000 -0700
+++ getmail-5.16-for-python-2.6/getmail 2021-11-03 09:49:03.140267922 -0700
@@ -1,11 +1,6 @@
#!/usr/bin/env python2
import sys
-
-if sys.hexversion < 0x2030300:
- raise ImportError('getmail version 5 requires Python version 2.3.3 '
- 'or later')
-
import os.path
import time
import ConfigParser
diff -ur getmail-5.16/getmailcore/__init__.py getmail-5.16-for-python-2.6/getmailcore/__init__.py
--- getmail-5.16/getmailcore/__init__.py 2021-10-31 15:19:59.000000000 -0700
+++ getmail-5.16-for-python-2.6/getmailcore/__init__.py 2021-11-01 23:09:06.349344847 -0700
@@ -11,11 +11,6 @@
You should have received a copy of the license in the file COPYING.
'''
-import sys
-if sys.hexversion < 0x2030300:
- raise ImportError('getmail version 5 requires Python version 2.3.3'
- ' or later')
-
__version__ = '5.16'
__all__ = [
diff -ur getmail-5.16/getmail_fetch getmail-5.16-for-python-2.6/getmail_fetch
--- getmail-5.16/getmail_fetch 2021-10-31 15:17:46.000000000 -0700
+++ getmail-5.16-for-python-2.6/getmail_fetch 2021-11-03 09:49:03.140267922 -0700
@@ -1,11 +1,6 @@
#!/usr/bin/env python2
import sys
-
-if sys.hexversion < 0x2030300:
- raise ImportError('getmail version 5 requires Python version 2.3.3 '
- 'or later')
-
import os
import socket
import poplib
diff -ur getmail-5.16/getmail_maildir getmail-5.16-for-python-2.6/getmail_maildir
--- getmail-5.16/getmail_maildir 2021-10-31 15:17:40.000000000 -0700
+++ getmail-5.16-for-python-2.6/getmail_maildir 2021-11-03 09:49:03.140267922 -0700
@@ -19,11 +19,6 @@
Street, Fifth Floor, Boston, MA 02110-1301 USA.
'''
import sys
-
-if sys.hexversion < 0x2030300:
- raise ImportError('getmail version 5 requires Python version 2.3.3 '
- 'or later')
-
import os
from getmailcore.message import Message
diff -ur getmail-5.16/getmail_mbox getmail-5.16-for-python-2.6/getmail_mbox
--- getmail-5.16/getmail_mbox 2021-10-31 15:17:32.000000000 -0700
+++ getmail-5.16-for-python-2.6/getmail_mbox 2021-11-03 09:49:03.140267922 -0700
@@ -19,11 +19,6 @@
Street, Fifth Floor, Boston, MA 02110-1301 USA.
'''
import sys
-
-if sys.hexversion < 0x2030300:
- raise ImportError('getmail version 5 requires Python version 2.3.3 '
- 'or later')
-
import os
import email
from getmailcore.exceptions import *
diff -ur getmail-5.16/setup.py getmail-5.16-for-python-2.6/setup.py
--- getmail-5.16/setup.py 2021-10-31 15:19:59.000000000 -0700
+++ getmail-5.16-for-python-2.6/setup.py 2021-11-01 23:11:42.950439093 -0700
@@ -1,9 +1,6 @@
#!/usr/bin/env python2
import sys
-if sys.hexversion < 0x2030300:
- raise ImportError('getmail version 4 requires Python version 2.3.3 or later')
-
import os.path
from distutils.core import setup
import distutils.sysconfig
diff -ur getmail-5.16/getmail.spec getmail-5.16-for-python-2.6/getmail.spec
--- getmail-5.16/getmail.spec 2021-10-31 16:27:26.000000000 -0700
+++ getmail-5.16-for-python-2.6/getmail.spec 2021-11-01 23:04:17.807303926 -0700
@@ -12,8 +12,8 @@
Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root
BuildArch: noarch
-BuildRequires: python-devel >= 2.3.3
-Requires: python >= 2.3.3
+BuildRequires: python-devel >= 2.6
+Requires: python >= 2.6
%description
getmail is intended as a simple replacement for fetchmail for those people
diff -ur getmail-5.16/setup.cfg getmail-5.16-for-python-2.6/setup.cfg
--- getmail-5.16/setup.cfg 2009-01-08 13:55:25.000000000 -0800
+++ getmail-5.16-for-python-2.6/setup.cfg 2021-11-01 23:04:17.815303983 -0700
@@ -22,4 +22,4 @@
binary_only = True
group = Applications/Email
release = 1
-requires = python >= 2.3.3
+requires = python >= 2.6