Repository: pydicom/pydicom

Issue:
[python 3.8] failing tests: various issues but "max recursion depth reached" seems to be one
#### Description
Fedora is beginning to test python packages against python 3.8. Pydicom builds but tests fail with errors.

#### Steps/Code to Reproduce

```
python setup.py build
python setup.py install
pytest
```

The complete build log is attached. It includes the complete build process. The root log is also attached. These are the versions of other python libraries that are in use:

```
python3-dateutil-1:2.8.0-5.fc32.noarch
python3-devel-3.8.0~b3-4.fc32.x86_64
python3-numpy-1:1.17.0-3.fc32.x86_64
python3-numpydoc-0.9.1-3.fc32.noarch
python3-pytest-4.6.5-3.fc32.noarch
python3-setuptools-41.0.1-8.fc32.noarch
python3-six-1.12.0-5.fc32.noarch
```

[build-log.txt](https://github.com/pydicom/pydicom/files/3527558/build-log.txt)
[root-log.txt](https://github.com/pydicom/pydicom/files/3527559/root-log.txt)



Discussion:
Thanks, @sanjayankur31, we'll look into it.
Looks like the [culprit](https://docs.python.org/3.8/whatsnew/3.8.html#changes-in-python-behavior) might be:

> Removed `__str__` implementations from builtin types bool, int, float, complex and few classes from the standard library. They now inherit `__str__()` from object. As result, defining the `__repr__()` method in the subclass of these classes will affect they string representation.

The unit test results in the build log shows issues with `DSfloat.__str__()/DSfloat.__repr__()` and `IS.__repr__()` on lines [350](https://github.com/pydicom/pydicom/blob/6d8ef0bfcec983e5f8bd8a2e359ff318fe9fcf65/pydicom/valuerep.py#L353)/353 and [520](https://github.com/pydicom/pydicom/blob/6d8ef0bfcec983e5f8bd8a2e359ff318fe9fcf65/pydicom/valuerep.py#L520) of current master.


Patch:
diff --git a/pydicom/valuerep.py b/pydicom/valuerep.py
--- a/pydicom/valuerep.py
+++ b/pydicom/valuerep.py
@@ -346,11 +346,12 @@ def __init__(self, val):
     def __str__(self):
         if hasattr(self, 'original_string'):
             return self.original_string
-        else:
-            return super(DSfloat, self).__str__()
+
+        # Issue #937 (Python 3.8 compatibility)
+        return repr(self)[1:-1]
 
     def __repr__(self):
-        return "\"" + str(self) + "\""
+        return '"{}"'.format(super(DSfloat, self).__repr__())
 
 
 class DSdecimal(Decimal):
@@ -513,11 +514,15 @@ def __init__(self, val):
         elif isinstance(val, IS) and hasattr(val, 'original_string'):
             self.original_string = val.original_string
 
-    def __repr__(self):
+    def __str__(self):
         if hasattr(self, 'original_string'):
-            return "\"" + self.original_string + "\""
-        else:
-            return "\"" + int.__str__(self) + "\""
+            return self.original_string
+
+        # Issue #937 (Python 3.8 compatibility)
+        return repr(self)[1:-1]
+
+    def __repr__(self):
+        return '"{}"'.format(super(IS, self).__repr__())
 
 
 def MultiString(val, valtype=str):


Test patch:
diff --git a/pydicom/tests/test_valuerep.py b/pydicom/tests/test_valuerep.py
--- a/pydicom/tests/test_valuerep.py
+++ b/pydicom/tests/test_valuerep.py
@@ -90,7 +90,6 @@ def test_pickling(self):
 
 class TestDS(object):
     """Unit tests for DS values"""
-
     def test_empty_value(self):
         assert DS(None) is None
         assert '' == DS('')
@@ -106,7 +105,6 @@ def test_float_values(self):
 
 class TestDSfloat(object):
     """Unit tests for pickling DSfloat"""
-
     def test_pickling(self):
         # Check that a pickled DSFloat is read back properly
         x = pydicom.valuerep.DSfloat(9.0)
@@ -116,10 +114,25 @@ def test_pickling(self):
         assert x.real == x2.real
         assert x.original_string == x2.original_string
 
+    def test_str(self):
+        """Test DSfloat.__str__()."""
+        val = pydicom.valuerep.DSfloat(1.1)
+        assert '1.1' == str(val)
+
+        val = pydicom.valuerep.DSfloat('1.1')
+        assert '1.1' == str(val)
+
+    def test_repr(self):
+        """Test DSfloat.__repr__()."""
+        val = pydicom.valuerep.DSfloat(1.1)
+        assert '"1.1"' == repr(val)
+
+        val = pydicom.valuerep.DSfloat('1.1')
+        assert '"1.1"' == repr(val)
+
 
 class TestDSdecimal(object):
     """Unit tests for pickling DSdecimal"""
-
     def test_pickling(self):
         # Check that a pickled DSdecimal is read back properly
         # DSdecimal actually prefers original_string when
@@ -142,7 +155,6 @@ def test_float_value(self):
 
 class TestIS(object):
     """Unit tests for IS"""
-
     def test_empty_value(self):
         assert IS(None) is None
         assert '' == IS('')
@@ -182,6 +194,22 @@ def test_overflow(self):
             pydicom.valuerep.IS(3103050000)
         config.enforce_valid_values = original_flag
 
+    def test_str(self):
+        """Test IS.__str__()."""
+        val = pydicom.valuerep.IS(1)
+        assert '1' == str(val)
+
+        val = pydicom.valuerep.IS('1')
+        assert '1' == str(val)
+
+    def test_repr(self):
+        """Test IS.__repr__()."""
+        val = pydicom.valuerep.IS(1)
+        assert '"1"' == repr(val)
+
+        val = pydicom.valuerep.IS('1')
+        assert '"1"' == repr(val)
+
 
 class TestBadValueRead(object):
     """Unit tests for handling a bad value for a VR