Opened 12 years ago

Closed 12 years ago

Last modified 10 years ago

#17212 closed Bug (fixed)

django.contrib.gis.geos.error.GEOSException: Could not parse version info string "3.4.0dev-CAPI-1.8.0"

Reported by: strk@… Owned by: nobody
Component: GIS Version: 1.3
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

Can't use the module with a development version of GEOS, due the version string parser chocking.

  File "/home/strk/.virtualenvs/qgis_django/lib/python2.6/site-packages/django/contrib/gis/geos/libgeos.py", line 113, in geos_version_info

Actual version is 1.3.1-final

Attachments (1)

geos-dev.patch (687 bytes ) - added by strk@… 12 years ago.
The patch

Download all attachments as: .zip

Change History (10)

comment:1 by strk@…, 12 years ago

For the record, here's my string: "3.4.0dev-CAPI-1.8.0"

by strk@…, 12 years ago

Attachment: geos-dev.patch added

The patch

comment:2 by strk@…, 12 years ago

Has patch: set

comment:3 by Aymeric Augustin, 12 years ago

Triage Stage: UnreviewedAccepted
Type: UncategorizedBug

Looks good to me.

Generally, each patch must include tests, but in this case, I sounds overkill. I'll defer to the GIS maintainer to decide.

comment:4 by Aymeric Augustin, 12 years ago

Patch needs improvement: set

Note that you should generate your patch from the "trunk" directory to avoid ambiguities.

comment:5 by jbronn, 12 years ago

Resolution: fixed
Status: newclosed

In [17682]:

Fixed #17212 -- Made GEOS version regular expression more robust. Thanks, strk.

comment:6 by nachopro@…, 11 years ago

Hi, I have this problem from my ArchLinux last update:
GEOSException: Could not parse version info string "3.4.2-CAPI-1.8.2 r3921"

My "solution" was edit the geos_version_info function changing this line:
ver = geos_version().decode()

with this line:
ver = geos_version().decode().split(' ')[0]

Thanks!

comment:7 by Claude Paroz, 11 years ago

We have improved once again the parsing in #20036, which is in the latest 1.5 stable version and up.

comment:8 by anonymous, 10 years ago

So no patch for 1.4.X ?

comment:9 by Claude Paroz, 10 years ago

Here's a patch you should be able to manually apply to 1.4:

diff --git a/django/contrib/gis/geos/libgeos.py b/django/contrib/gis/geos/libgeos.py
index f011208..05e5d12 100644
--- a/django/contrib/gis/geos/libgeos.py
+++ b/django/contrib/gis/geos/libgeos.py
@@ -108,8 +108,11 @@ def get_pointer_arr(n):
 geos_version.restype = c_char_p
 
 # 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'
-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+)$')
+# '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+))'
+    r'((rc(?P<release_candidate>\d+))|dev)?-CAPI-(?P<capi_version>\d+\.\d+\.\d+)( r\d+)?$'
+)
 def geos_version_info():
     """
     Returns a dictionary containing the various version metadata parsed from
Note: See TracTickets for help on using tickets.
Back to Top