Add deprecation warning for Python 2.6 (#5391)

* Add deprecation warning for Python 2.6

* Allow disabling Python 2.6 warning
This commit is contained in:
ohemorange
2018-01-09 16:11:04 -08:00
committed by Brad Warren
parent 887a6bcfce
commit f5a02714cd
2 changed files with 19 additions and 9 deletions
+7 -6
View File
@@ -13,9 +13,10 @@ supported version: `draft-ietf-acme-01`_.
import sys
import warnings
if sys.version_info[:2] == (3, 3):
warnings.warn(
"Python 3.3 support will be dropped in the next release of "
"acme. Please upgrade your Python version.",
PendingDeprecationWarning,
) #pragma: no cover
for (major, minor) in [(2, 6), (3, 3)]:
if sys.version_info[:2] == (major, minor):
warnings.warn(
"Python {0}.{1} support will be dropped in the next release of "
"acme. Please upgrade your Python version.".format(major, minor),
DeprecationWarning,
) #pragma: no cover
+12 -3
View File
@@ -4,6 +4,7 @@ import functools
import logging.handlers
import os
import sys
import warnings
import configobj
import josepy as jose
@@ -1217,9 +1218,17 @@ def main(cli_args=sys.argv[1:]):
# Let plugins_cmd be run as un-privileged user.
if config.func != plugins_cmd:
raise
if sys.version_info[:2] == (3, 3):
logger.warning("Python 3.3 support will be dropped in the next release "
"of Certbot - please upgrade your Python version.")
deprecation_fmt = (
"Python %s.%s support will be dropped in the next "
"release of Certbot - please upgrade your Python version.")
# We use the warnings system for Python 2.6 and logging for Python 3
# because DeprecationWarnings are only reported by default in Python <= 2.6
# and warnings can be disabled by the user.
if sys.version_info[:2] == (2, 6):
warning = deprecation_fmt % sys.version_info[:2]
warnings.warn(warning, DeprecationWarning)
elif sys.version_info[:2] == (3, 3):
logger.warning(deprecation_fmt, *sys.version_info[:2])
set_displayer(config)