From 6ebdac027e0735777ed4adbc665c90292e86af4c Mon Sep 17 00:00:00 2001 From: JamesParrott <80779630+JamesParrott@users.noreply.github.com> Date: Fri, 20 Sep 2024 10:40:58 +0100 Subject: [PATCH 1/4] Add draft user warning --- shapefile.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/shapefile.py b/shapefile.py index 12af74d..b924b24 100644 --- a/shapefile.py +++ b/shapefile.py @@ -14,7 +14,9 @@ import os import sys import tempfile +import textwrap import time +import warnings import zipfile from datetime import date from struct import Struct, calcsize, error, pack, unpack @@ -93,6 +95,27 @@ from urllib2 import HTTPError, Request, urlopen from urlparse import urlparse, urlunparse +if sys.version_info < (3, 9): + warnings.showwarning( + textwrap.dedent("""\ + Warning! + + The PyShp developers propose to drop support for Pythons 3.8 and earlier, including Python 2. + Thereafter, Python version support will follow the official Python release + cycle: https://devguide.python.org/versions/. This will make Python 3.9 the earliest + supported version until October 2025. + + The reasoning behind this is available in the following discussion: + https://github.com/GeospatialPython/pyshp/discussions/290 + Please post any feedback there. + + Many thanks, + """), + category=UserWarning, + filename=__name__, + lineno=99, + ) + # Helpers From 3722683f6f858124908f73b7b7eba9543d5211e3 Mon Sep 17 00:00:00 2001 From: JamesParrott <80779630+JamesParrott@users.noreply.github.com> Date: Fri, 20 Sep 2024 10:41:58 +0100 Subject: [PATCH 2/4] Update .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index f6d6332..dcb9eb1 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,4 @@ dist/ *.py[cod] .vscode .dmypy.json +.python-version From 3063d27481442531ea81f2ad22887deb6399e701 Mon Sep 17 00:00:00 2001 From: JamesParrott <80779630+JamesParrott@users.noreply.github.com> Date: Fri, 20 Sep 2024 10:56:30 +0100 Subject: [PATCH 3/4] Send warning message to logger as well --- shapefile.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/shapefile.py b/shapefile.py index b924b24..f8fa434 100644 --- a/shapefile.py +++ b/shapefile.py @@ -96,24 +96,26 @@ from urlparse import urlparse, urlunparse if sys.version_info < (3, 9): - warnings.showwarning( - textwrap.dedent("""\ + message = textwrap.dedent("""\ Warning! - The PyShp developers propose to drop support for Pythons 3.8 and earlier, including Python 2. + It is proposed to drop support for Pythons 3.8 and earlier, including Python 2. Thereafter, Python version support will follow the official Python release - cycle: https://devguide.python.org/versions/. This will make Python 3.9 the earliest - supported version until October 2025. + cycle: https://devguide.python.org/versions/. This will make Python 3.9 the + earliest supported version until October 2025. - The reasoning behind this is available in the following discussion: + For more information, and to send the developers your feedback please + see the following discussion: https://github.com/GeospatialPython/pyshp/discussions/290 - Please post any feedback there. Many thanks, - """), + """) + logger.warning(message) + warnings.showwarning( + message, category=UserWarning, filename=__name__, - lineno=99, + lineno=115, ) From fb03fe71cea010eb81eb9bec63f41f27ebd16170 Mon Sep 17 00:00:00 2001 From: JamesParrott <80779630+JamesParrott@users.noreply.github.com> Date: Fri, 20 Sep 2024 11:05:18 +0100 Subject: [PATCH 4/4] Attempt to fix Pytest error in Python 2 --- shapefile.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/shapefile.py b/shapefile.py index f8fa434..6e8b2f2 100644 --- a/shapefile.py +++ b/shapefile.py @@ -111,12 +111,14 @@ Many thanks, """) logger.warning(message) - warnings.showwarning( - message, - category=UserWarning, - filename=__name__, - lineno=115, - ) + warning = UserWarning(message) + warnings.warn(warning) + # warnings.showwarning( + # message, + # category=UserWarning, + # filename=__name__, + # lineno=115, + # ) # Helpers