Description: Fix a segfault when doing a noop swapaxes
Author: Brian Kearns <bdkearns@gmail.com>
Bug-Upstream: https://bitbucket.org/pypy/pypy/issue/1872
Origin: upstream, https://bitbucket.org/pypy/pypy/commits/8faa11984f7a

--- a/pypy/module/micronumpy/ndarray.py
+++ b/pypy/module/micronumpy/ndarray.py
@@ -407,7 +407,7 @@
         --------
         numpy.swapaxes : equivalent function
         """
-        if self.is_scalar():
+        if axis1 == axis2 or len(self.get_shape()) <= 1:
             return self
         return self.implementation.swapaxes(space, self, axis1, axis2)
 
--- a/pypy/module/micronumpy/test/test_ndarray.py
+++ b/pypy/module/micronumpy/test/test_ndarray.py
@@ -2020,6 +2020,10 @@
 
     def test_swapaxes(self):
         from numpypy import array
+        x = array([])
+        assert x.swapaxes(0, 2) is x
+        x = array([[1, 2]])
+        assert x.swapaxes(0, 0) is x
         # testcases from numpy docstring
         x = array([[1, 2, 3]])
         assert (x.swapaxes(0, 1) == array([[1], [2], [3]])).all()
