Repository: spyder-ide/spyder

Issue:
Error when trying to inspect a 'NaT' in Variable Explorer
## Description

### What steps will reproduce the problem?

<!--- You can use Markdown here --->

In [135]: x = df['remove_time'][2]

In [136]: pd.Timestamp.max
Out[136]: Timestamp('2262-04-11 23:47:16.854775807')

In [137]: print(df['remove_time'][2])
NaT

In [138]: x = df['remove_time'][2]

In [139]: 


Then, I click the 'x' in Variable Explorer.


### Traceback
```python-traceback
  File "/home/hechu/anaconda3/lib/python3.7/site-packages/spyder/widgets/variableexplorer/collectionseditor.py", line 615, in setEditorData
    editor.setDateTime(QDateTime(value.date(), value.time()))
  File "pandas/_libs/tslibs/nattype.pyx", line 59, in pandas._libs.tslibs.nattype._make_error_func.f
ValueError: NaTType does not support time
```

## Versions

* Spyder version: 3.3.1 
* Python version: 3.7.0
* Qt version: 5.9.6
* PyQt5 version: 5.9.2
* Operating System: Linux 4.15.0-39-generic

### Dependencies

```
pyflakes >=0.6.0  :  2.0.0 (OK)
pycodestyle >=2.3 :  2.4.0 (OK)
pygments >=2.0    :  2.2.0 (OK)
sphinx >=0.6.6    :  1.8.2 (OK)
rope >=0.9.4      :  0.11.0 (OK)
jedi >=0.9.0      :  0.13.1 (OK)
psutil >=0.3      :  5.4.8 (OK)
nbconvert >=4.0   :  5.3.1 (OK)
pandas >=0.13.1   :  0.23.4 (OK)
numpy >=1.7       :  1.15.1 (OK)
sympy >=0.7.3     :  1.3 (OK)
cython >=0.21     :  0.29 (OK)
qtconsole >=4.2.0 :  4.4.2 (OK)
IPython >=4.0     :  7.1.1 (OK)
matplotlib >=2.0.0:  2.2.3 (OK)
pylint >=0.25     :  2.1.1 (OK)
```



Discussion:
@juanis2112, I think we should catch the error and pass in this case, because there's nothing we can show about a NaT.

Some helpful linlks:

* What is a NaT? https://pandas.pydata.org/pandas-docs/stable/missing_data.html#datetimes
* How to check for NaTs? https://stackoverflow.com/q/49435317/438386
Thanks for the bug fix, I will learn the link above and try to avoid show NaT in Variable Explorer.
@gzhechu, we haven't been able to generate a fix for this problem, but we'll try to do it for Spyder 4.
I think this is related to #12550 @dalthviz 
Should we mark this as duplicated @goanpeca or maybe the other one as duplicated of this one ?
Up to you :-), it might be a different but related issue. 

Resolving patch:
diff --git a/spyder/plugins/variableexplorer/widgets/collectionsdelegate.py b/spyder/plugins/variableexplorer/widgets/collectionsdelegate.py
--- a/spyder/plugins/variableexplorer/widgets/collectionsdelegate.py
+++ b/spyder/plugins/variableexplorer/widgets/collectionsdelegate.py
@@ -168,7 +168,15 @@ def createEditor(self, parent, option, index, object_explorer=False):
             return None
         # QDateEdit and QDateTimeEdit for a dates or datetime respectively
         elif isinstance(value, datetime.date) and not object_explorer:
+            # Needed to handle NaT values
+            # See spyder-ide/spyder#8329
+            try:
+                value.time()
+            except ValueError:
+                self.sig_editor_shown.emit()
+                return None
             if readonly:
+                self.sig_editor_shown.emit()
                 return None
             else:
                 if isinstance(value, datetime.datetime):
@@ -192,6 +200,7 @@ def createEditor(self, parent, option, index, object_explorer=False):
         # QLineEdit for an individual value (int, float, short string, etc)
         elif is_editable_type(value) and not object_explorer:
             if readonly:
+                self.sig_editor_shown.emit()
                 return None
             else:
                 editor = QLineEdit(parent=parent)


Test patch: