mirror of
https://github.com/django/django.git
synced 2025-06-08 21:19:13 +00:00
[1.4.x] Fixed #20036 -- Improved GEOS version string parsing
Thanks chikiro.spam at gmail.com for the report.
This commit is contained in:
parent
065caafa70
commit
ba2be27613
@ -101,8 +101,11 @@ geos_version.argtypes = None
|
|||||||
geos_version.restype = c_char_p
|
geos_version.restype = c_char_p
|
||||||
|
|
||||||
# Regular expression should be able to parse version strings such as
|
# Regular expression should be able to parse version strings such as
|
||||||
# '3.0.0rc4-CAPI-1.3.3', '3.0.0-CAPI-1.4.1' or '3.4.0dev-CAPI-1.8.0'
|
# '3.0.0rc4-CAPI-1.3.3', '3.0.0-CAPI-1.4.1', '3.4.0dev-CAPI-1.8.0' or '3.4.0dev-CAPI-1.8.0 r0'
|
||||||
version_regex = re.compile(r'^(?P<version>(?P<major>\d+)\.(?P<minor>\d+)\.(?P<subminor>\d+))((rc(?P<release_candidate>\d+))|dev)?-CAPI-(?P<capi_version>\d+\.\d+\.\d+)$')
|
version_regex = re.compile(
|
||||||
|
r'^(?P<version>(?P<major>\d+)\.(?P<minor>\d+)\.(?P<subminor>\d+))'
|
||||||
|
r'((rc(?P<release_candidate>\d+))|dev)?-CAPI-(?P<capi_version>\d+\.\d+\.\d+)( r\d+)?$'
|
||||||
|
)
|
||||||
def geos_version_info():
|
def geos_version_info():
|
||||||
"""
|
"""
|
||||||
Returns a dictionary containing the various version metadata parsed from
|
Returns a dictionary containing the various version metadata parsed from
|
||||||
@ -112,8 +115,10 @@ def geos_version_info():
|
|||||||
"""
|
"""
|
||||||
ver = geos_version()
|
ver = geos_version()
|
||||||
m = version_regex.match(ver)
|
m = version_regex.match(ver)
|
||||||
if not m: raise GEOSException('Could not parse version info string "%s"' % ver)
|
if not m:
|
||||||
return dict((key, m.group(key)) for key in ('version', 'release_candidate', 'capi_version', 'major', 'minor', 'subminor'))
|
raise GEOSException('Could not parse version info string "%s"' % ver)
|
||||||
|
return dict((key, m.group(key)) for key in (
|
||||||
|
'version', 'release_candidate', 'capi_version', 'major', 'minor', 'subminor'))
|
||||||
|
|
||||||
# Version numbers and whether or not prepared geometry support is available.
|
# Version numbers and whether or not prepared geometry support is available.
|
||||||
_verinfo = geos_version_info()
|
_verinfo = geos_version_info()
|
||||||
|
@ -1050,15 +1050,17 @@ class GEOSTest(unittest.TestCase, TestDataMixin):
|
|||||||
print "\nEND - expecting GEOS_NOTICE; safe to ignore.\n"
|
print "\nEND - expecting GEOS_NOTICE; safe to ignore.\n"
|
||||||
|
|
||||||
def test28_geos_version(self):
|
def test28_geos_version(self):
|
||||||
"Testing the GEOS version regular expression."
|
"""Testing the GEOS version regular expression."""
|
||||||
from django.contrib.gis.geos.libgeos import version_regex
|
from django.contrib.gis.geos.libgeos import version_regex
|
||||||
versions = [ ('3.0.0rc4-CAPI-1.3.3', '3.0.0'),
|
versions = [('3.0.0rc4-CAPI-1.3.3', '3.0.0', '1.3.3'),
|
||||||
('3.0.0-CAPI-1.4.1', '3.0.0'),
|
('3.0.0-CAPI-1.4.1', '3.0.0', '1.4.1'),
|
||||||
('3.4.0dev-CAPI-1.8.0', '3.4.0') ]
|
('3.4.0dev-CAPI-1.8.0', '3.4.0', '1.8.0'),
|
||||||
for v, expected in versions:
|
('3.4.0dev-CAPI-1.8.0 r0', '3.4.0', '1.8.0')]
|
||||||
m = version_regex.match(v)
|
for v_init, v_geos, v_capi in versions:
|
||||||
self.assertTrue(m)
|
m = version_regex.match(v_init)
|
||||||
self.assertEqual(m.group('version'), expected)
|
self.assertTrue(m, msg="Unable to parse the version string '%s'" % v_init)
|
||||||
|
self.assertEqual(m.group('version'), v_geos)
|
||||||
|
self.assertEqual(m.group('capi_version'), v_capi)
|
||||||
|
|
||||||
|
|
||||||
def suite():
|
def suite():
|
||||||
|
@ -4,10 +4,14 @@ Django 1.4.16 release notes
|
|||||||
|
|
||||||
*Under development*
|
*Under development*
|
||||||
|
|
||||||
Django 1.4.16 fixes a regression in the 1.4.14 security release.
|
Django 1.4.16 fixes a regression in the 1.4.14 security release and a bug
|
||||||
|
preventing the use of some GEOS versions with GeoDjango.
|
||||||
|
|
||||||
Bugfixes
|
Bugfixes
|
||||||
========
|
========
|
||||||
|
|
||||||
* Allowed inline and hidden references to admin fields
|
* Allowed inline and hidden references to admin fields
|
||||||
(`#23431 <http://code.djangoproject.com/ticket/23431>`_).
|
(`#23431 <http://code.djangoproject.com/ticket/23431>`_).
|
||||||
|
|
||||||
|
* Fixed parsing of the GEOS version string
|
||||||
|
(`#20036 <http://code.djangoproject.com/ticket/20036>`_).
|
||||||
|
Loading…
x
Reference in New Issue
Block a user