Author: claudep
Date: 2012-04-12 09:35:28 -0700 (Thu, 12 Apr 2012)
New Revision: 17903

Modified:
   django/trunk/django/contrib/gis/geos/geometry.py
   django/trunk/django/contrib/gis/geos/tests/test_geos.py
   django/trunk/docs/ref/contrib/gis/geos.txt
Log:
Fixed #18039 -- Changed geometry transform without a SRID raise a GEOSException.

This was planned in the official deprecation timeline for 1.5.


Modified: django/trunk/django/contrib/gis/geos/geometry.py
===================================================================
--- django/trunk/django/contrib/gis/geos/geometry.py    2012-04-11 21:35:08 UTC 
(rev 17902)
+++ django/trunk/django/contrib/gis/geos/geometry.py    2012-04-12 16:35:28 UTC 
(rev 17903)
@@ -3,7 +3,6 @@
  inherit from this object.
 """
 # Python, ctypes and types dependencies.
-import warnings
 from ctypes import addressof, byref, c_double
 
 # super-class for mutable list behavior
@@ -507,11 +506,7 @@
                 return
 
         if (srid is None) or (srid < 0):
-            warnings.warn("Calling transform() with no SRID set does no 
transformation!",
-                          stacklevel=2)
-            warnings.warn("Calling transform() with no SRID will raise 
GEOSException in v1.5",
-                          FutureWarning, stacklevel=2)
-            return
+            raise GEOSException("Calling transform() with no SRID set is not 
supported")
 
         if not gdal.HAS_GDAL:
             raise GEOSException("GDAL library is not available to transform() 
geometry.")

Modified: django/trunk/django/contrib/gis/geos/tests/test_geos.py
===================================================================
--- django/trunk/django/contrib/gis/geos/tests/test_geos.py     2012-04-11 
21:35:08 UTC (rev 17902)
+++ django/trunk/django/contrib/gis/geos/tests/test_geos.py     2012-04-12 
16:35:28 UTC (rev 17903)
@@ -891,64 +891,20 @@
             gdal.HAS_GDAL = old_has_gdal
 
     def test23_transform_nosrid(self):
-        """ Testing `transform` method (no SRID) """
-        # Raise a warning if SRID <0/None.
-        import warnings
-        print "\nBEGIN - expecting Warnings; safe to ignore.\n"
+        """ Testing `transform` method (no SRID or negative SRID) """
 
-        # Test for do-nothing behavior.
-        try:
-            # Keeping line-noise down by only printing the relevant
-            # warnings once.
-            warnings.simplefilter('once', UserWarning)
-            warnings.simplefilter('once', FutureWarning)
+        g = GEOSGeometry('POINT (-104.609 38.255)', srid=None)
+        self.assertRaises(GEOSException, g.transform, 2774)
 
-            g = GEOSGeometry('POINT (-104.609 38.255)', srid=None)
-            g.transform(2774)
-            self.assertEqual(g.tuple, (-104.609, 38.255))
-            self.assertEqual(g.srid, None)
+        g = GEOSGeometry('POINT (-104.609 38.255)', srid=None)
+        self.assertRaises(GEOSException, g.transform, 2774, clone=True)
 
-            g = GEOSGeometry('POINT (-104.609 38.255)', srid=None)
-            g1 = g.transform(2774, clone=True)
-            self.assertTrue(g1 is None)
+        g = GEOSGeometry('POINT (-104.609 38.255)', srid=-1)
+        self.assertRaises(GEOSException, g.transform, 2774)
 
-            g = GEOSGeometry('POINT (-104.609 38.255)', srid=-1)
-            g.transform(2774)
-            self.assertEqual(g.tuple, (-104.609, 38.255))
-            self.assertEqual(g.srid, -1)
+        g = GEOSGeometry('POINT (-104.609 38.255)', srid=-1)
+        self.assertRaises(GEOSException, g.transform, 2774, clone=True)
 
-            g = GEOSGeometry('POINT (-104.609 38.255)', srid=-1)
-            g1 = g.transform(2774, clone=True)
-            self.assertTrue(g1 is None)
-
-        finally:
-            warnings.simplefilter('default', UserWarning)
-            warnings.simplefilter('default', FutureWarning)
-
-        print "\nEND - expecting Warnings; safe to ignore.\n"
-
-
-        # test warning is raised
-        try:
-            warnings.simplefilter('error', FutureWarning)
-            warnings.simplefilter('ignore', UserWarning)
-
-            g = GEOSGeometry('POINT (-104.609 38.255)', srid=None)
-            self.assertRaises(FutureWarning, g.transform, 2774)
-
-            g = GEOSGeometry('POINT (-104.609 38.255)', srid=None)
-            self.assertRaises(FutureWarning, g.transform, 2774, clone=True)
-
-            g = GEOSGeometry('POINT (-104.609 38.255)', srid=-1)
-            self.assertRaises(FutureWarning, g.transform, 2774)
-
-            g = GEOSGeometry('POINT (-104.609 38.255)', srid=-1)
-            self.assertRaises(FutureWarning, g.transform, 2774, clone=True)
-        finally:
-            warnings.simplefilter('default', FutureWarning)
-            warnings.simplefilter('default', UserWarning)
-
-
     def test23_transform_nogdal(self):
         """ Testing `transform` method (GDAL not available) """
         old_has_gdal = gdal.HAS_GDAL

Modified: django/trunk/docs/ref/contrib/gis/geos.txt
===================================================================
--- django/trunk/docs/ref/contrib/gis/geos.txt  2012-04-11 21:35:08 UTC (rev 
17902)
+++ django/trunk/docs/ref/contrib/gis/geos.txt  2012-04-12 16:35:28 UTC (rev 
17903)
@@ -542,9 +542,8 @@
    Prior to 1.3, this method would silently no-op if GDAL was not available.
    Now, a :class:`~django.contrib.gis.geos.GEOSException` is raised as
    application code relying on this behavior is in error. In addition,
-   use of this method when the SRID is ``None`` or less than 0 now generates
-   a warning because a :class:`~django.contrib.gis.geos.GEOSException` will
-   be raised instead in version 1.5.
+   use of this method when the SRID is ``None`` or less than 0 now also 
generates
+   a :class:`~django.contrib.gis.geos.GEOSException`.
 
 
 ``Point``

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to