From 84e35f4679622bf6cf7c1763bee3ce9af9c892ff Mon Sep 17 00:00:00 2001 From: Diederik van der Boor Date: Sun, 23 Feb 2020 22:04:18 +0100 Subject: [PATCH] Fixed #31292 -- Fixed django.contrib.gis.gdal.gdal_full_version() crash. --- django/contrib/gis/gdal/libgdal.py | 2 +- tests/gis_tests/gdal_tests/tests.py | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/django/contrib/gis/gdal/libgdal.py b/django/contrib/gis/gdal/libgdal.py index 5bdb362db7..f825abe8ba 100644 --- a/django/contrib/gis/gdal/libgdal.py +++ b/django/contrib/gis/gdal/libgdal.py @@ -80,7 +80,7 @@ def gdal_version(): def gdal_full_version(): "Return the full GDAL version information." - return _version_info('') + return _version_info(b'') version_regex = _lazy_re_compile(r'^(?P\d+)\.(?P\d+)(\.(?P\d+))?') diff --git a/tests/gis_tests/gdal_tests/tests.py b/tests/gis_tests/gdal_tests/tests.py index a1847cd677..607753271f 100644 --- a/tests/gis_tests/gdal_tests/tests.py +++ b/tests/gis_tests/gdal_tests/tests.py @@ -1,6 +1,8 @@ import unittest -from django.contrib.gis.gdal import GDAL_VERSION, gdal_version +from django.contrib.gis.gdal import ( + GDAL_VERSION, gdal_full_version, gdal_version, +) class GDALTest(unittest.TestCase): @@ -9,3 +11,8 @@ class GDALTest(unittest.TestCase): self.assertEqual(gdal_version(), ('%s.%s.%s' % GDAL_VERSION).encode()) else: self.assertIn(b'.', gdal_version()) + + def test_gdal_full_version(self): + full_version = gdal_full_version() + self.assertIn(gdal_version(), full_version) + self.assertTrue(full_version.startswith(b'GDAL'))