Repository: spyder-ide/spyder

Issue:
Annoying log message shown when autosave fails to work
## Description

### What steps will reproduce the problem?

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

None None None None None None None None None None None None None None None None None None 

### Traceback
```python-traceback
KeyError when retrieving hash of /Users/hamzz/PycharmProjects/MScAVR/ML/Assignments/Final Assignment/ReviewsPreprocessing.py
KeyError when retrieving hash of /Users/hamzz/PycharmProjects/MScAVR/ML/Assignments/Final Assignment/ReviewsPreprocessing.py
KeyError when retrieving hash of /Users/hamzz/PycharmProjects/MScAVR/ML/Assignments/Final Assignment/ReviewsPreprocessing.py
```

## Versions

* Spyder version: 5.3.3  (conda)
* Python version: 3.9.12 64-bit
* Qt version: 5.15.2
* PyQt5 version: 5.15.7
* Operating System: Darwin 22.1.0

### Dependencies

```
# Mandatory:
applaunchservices >=0.3.0     :  0.3.0 (OK)
atomicwrites >=1.2.0          :  1.4.0 (OK)
chardet >=2.0.0               :  4.0.0 (OK)
cloudpickle >=0.5.0           :  2.0.0 (OK)
cookiecutter >=1.6.0          :  1.7.3 (OK)
diff_match_patch >=20181111   :  20200713 (OK)
intervaltree >=3.0.2          :  3.1.0 (OK)
IPython >=7.31.1;<8.0.0       :  7.31.1 (OK)
jedi >=0.17.2;<0.19.0         :  0.18.1 (OK)
jellyfish >=0.7               :  0.9.0 (OK)
jsonschema >=3.2.0            :  4.16.0 (OK)
keyring >=17.0.0              :  23.4.0 (OK)
nbconvert >=4.0               :  6.4.4 (OK)
numpydoc >=0.6.0              :  1.4.0 (OK)
parso >=0.7.0;<0.9.0          :  0.8.3 (OK)
pexpect >=4.4.0               :  4.8.0 (OK)
pickleshare >=0.4             :  0.7.5 (OK)
psutil >=5.3                  :  5.9.0 (OK)
pygments >=2.0                :  2.11.2 (OK)
pylint >=2.5.0;<3.0           :  2.14.5 (OK)
pyls_spyder >=0.4.0           :  0.4.0 (OK)
pylsp >=1.5.0;<1.6.0          :  1.5.0 (OK)
pylsp_black >=1.2.0           :  1.2.1 (OK)
qdarkstyle >=3.0.2;<3.1.0     :  3.0.2 (OK)
qstylizer >=0.1.10            :  0.1.10 (OK)
qtawesome >=1.0.2             :  1.0.3 (OK)
qtconsole >=5.3.2;<5.4.0      :  5.3.2 (OK)
qtpy >=2.1.0                  :  2.2.0 (OK)
rtree >=0.9.7                 :  0.9.7 (OK)
setuptools >=49.6.0           :  63.4.1 (OK)
sphinx >=0.6.6                :  5.0.2 (OK)
spyder_kernels >=2.3.3;<2.4.0 :  2.3.3 (OK)
textdistance >=4.2.0          :  4.2.1 (OK)
three_merge >=0.1.1           :  0.1.1 (OK)
watchdog >=0.10.3             :  2.1.6 (OK)
zmq >=22.1.0                  :  23.2.0 (OK)

# Optional:
cython >=0.21                 :  0.29.32 (OK)
matplotlib >=3.0.0            :  3.5.2 (OK)
numpy >=1.7                   :  1.21.5 (OK)
pandas >=1.1.1                :  1.4.4 (OK)
scipy >=0.17.0                :  1.7.3 (OK)
sympy >=0.7.3                 :  1.10.1 (OK)
```



Discussion:
Hey @hamzzgab, thanks for reporting. That is a warning message, so you can simply ignore it for now. We'll avoid showing it to our users in our next version (5.4.2), to be released in February.

Resolving patch:
diff --git a/spyder/plugins/editor/utils/autosave.py b/spyder/plugins/editor/utils/autosave.py
--- a/spyder/plugins/editor/utils/autosave.py
+++ b/spyder/plugins/editor/utils/autosave.py
@@ -373,6 +373,7 @@ def maybe_autosave(self, index):
         finfo = self.stack.data[index]
         if finfo.newly_created:
             return
+
         orig_filename = finfo.filename
         try:
             orig_hash = self.file_hashes[orig_filename]
@@ -381,8 +382,9 @@ def maybe_autosave(self, index):
             # In this case, use an impossible value for the hash, so that
             # contents of buffer are considered different from contents of
             # original file.
-            logger.error('KeyError when retrieving hash of %s', orig_filename)
+            logger.debug('KeyError when retrieving hash of %s', orig_filename)
             orig_hash = None
+
         new_hash = self.stack.compute_hash(finfo)
         if orig_filename in self.name_mapping:
             autosave_filename = self.name_mapping[orig_filename]


Test patch: