Opened 4 years ago

Closed 3 years ago

Last modified 22 months 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@… 4 years ago.
The patch

Download all attachments as: .zip

Change History (10)

comment:1 Changed 4 years ago by strk@…

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

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

Changed 4 years ago by strk@…

The patch

comment:2 Changed 4 years ago by strk@…

  • Has patch set

comment:3 Changed 4 years ago by aaugustin

  • Triage Stage changed from Unreviewed to Accepted
  • Type changed from Uncategorized to Bug

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 Changed 4 years ago by aaugustin

  • Patch needs improvement set

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

comment:5 Changed 3 years ago by jbronn

  • Resolution set to fixed
  • Status changed from new to closed

In [17682]:

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

comment:6 Changed 23 months ago by nachopro@…

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 Changed 23 months ago by claudep

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

comment:8 Changed 22 months ago by anonymous

So no patch for 1.4.X ?

comment:9 Changed 22 months ago by claudep

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