diff --git a/doc/release_notes/v1.4.0.rst b/doc/release_notes/v1.4.0.rst
index 34d665f06..948b19df5 100644
--- a/doc/release_notes/v1.4.0.rst
+++ b/doc/release_notes/v1.4.0.rst
@@ -14,6 +14,7 @@ Fixes
 * Fixed handling of data too large to written in explicit transfer syntax
 * Fixed handling of known tags with VR UN (:issue:`899`)
 * Fixed assigning of empty values to data elements (:issue:`896`)
+* Fixed error in unpickling dataset (:issue:`947`)
 
 Enhancements
 ............
diff --git a/pydicom/dataset.py b/pydicom/dataset.py
index 3c5c6d2f2..2c631c8e2 100644
--- a/pydicom/dataset.py
+++ b/pydicom/dataset.py
@@ -766,21 +766,23 @@ class Dataset(dict):
               value (if present).
         """
         tag = tag_for_keyword(name)
-        if tag is None:  # `name` isn't a DICOM element keyword
-            # Try the base class attribute getter (fix for issue 332)
-            return object.__getattribute__(self, name)
-        tag = Tag(tag)
-        if tag not in self._dict:  # DICOM DataElement not in the Dataset
-            # Try the base class attribute getter (fix for issue 332)
-            return object.__getattribute__(self, name)
-        else:
-            data_elem = self[tag]
-            value = data_elem.value
-            if data_elem.VR == 'SQ':
-                # let a sequence know its parent dataset, as sequence items
-                # may need parent dataset tags to resolve ambiguous tags
-                value.parent = self
-            return value
+        if tag is not None:  # `name` isn't a DICOM element keyword
+            tag = Tag(tag)
+            if tag in self._dict:  # DICOM DataElement not in the Dataset
+                data_elem = self[tag]
+                value = data_elem.value
+                if data_elem.VR == 'SQ':
+                    # let a sequence know its parent dataset, as sequence items
+                    # may need parent dataset tags to resolve ambiguous tags
+                    value.parent = self
+                return value
+
+        # no tag or tag not contained in the dataset
+        if name == '_dict':
+            # special handling for contained dict, needed for pickle
+            return {}
+        # Try the base class attribute getter (fix for issue 332)
+        return object.__getattribute__(self, name)
 
     @property
     def _character_set(self):

Error when using pickle on a dataset
Hi,
I am using python 3.6.8, with Pydicom version 1.3.0, on Windows 10.
I have an error when I try to save and load a dataset using the pickle format.
I manage (no error) to save the dataset using pickle.dump() function, but I get an error when I try to load it. Here is the code:

````python
import pydicom
import pickle

dcmname='C:\\toto\IM-0511-0001.dcm' # path to the DICOM file
ds=pydicom.dcmread(dcmname) # load the DICOM file and obtain a dataset

filename='C:\\toto\dcm.pkl' # Name of the file where the pickle data will be saved
f=open(filename,'wb'); # open the file
pickle.dump({'ds': ds}, f); # save the dataset
f.close(); # close the file

f=open(filename,'rb'); # open the file
obj=pickle.load(f); # load the pickle file
f.close(); # close the file
````
I get the following error
````python
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "C:\toto\.conda\envs\marvelous\lib\site-packages\pydicom\dataset.py", line 1649, in __setitem__
    self._dict[tag] = data_element
  File "C:\toto\.conda\envs\my_env\lib\site-packages\pydicom\dataset.py", line 741, in __getattr__
    return object.__getattribute__(self, name)
AttributeError: 'Dataset' object has no attribute '_dict'
````
I found a workaround by setting the [protocol ](https://docs.python.org/3.6/library/pickle.html#pickle.DEFAULT_PROTOCOL) option of the `pickle.dump()` function to a value lower or equal than 1:
````python
import pydicom
import pickle

dcmname='C:\\toto\IM-0511-0001.dcm' # path to the DICOM file
ds=pydicom.dcmread(dcmname) # load the DICOM file and obtain a dataset

filename='C:\\toto\dcm.pkl' # Name of the file where the pickle data will be saved
f=open(filename,'wb'); # open the file
pickle.dump({'ds': ds}, f, protocol=1); # save the dataset
f.close(); # close the file

f=open(filename,'rb'); # open the file
obj=pickle.load(f); # load the pickle file
f.close(); # close the file
````
Other protocol value does not work (3, the default value, and 4), while I would like to continue to be able to use the default value of the protocol.

I think that the problem was not existing on previous release of Pydicom, so I guess that it appeared with version 1.3.0. 

I am sorry that I cannot share a DICOM file with you, but I have the problem with all my dicom files. I would be interested to know if someone else experienced the same problem.

Thanks!


diff --git a/pydicom/tests/test_dataset.py b/pydicom/tests/test_dataset.py
index 491f0b5e2..2ac9f066d 100644
--- a/pydicom/tests/test_dataset.py
+++ b/pydicom/tests/test_dataset.py
@@ -1382,6 +1382,14 @@ class TestFileDataset(object):
     def setup(self):
         self.test_file = get_testdata_files('CT_small.dcm')[0]
 
+    def test_pickle(self):
+        ds = pydicom.dcmread(self.test_file)
+        import pickle
+        s = pickle.dumps({'ds': ds})
+        ds1 = pickle.loads(s)['ds']
+        assert ds == ds1
+        assert ds1.Modality == 'CT'
+
     def test_equality_file_meta(self):
         """Dataset: equality returns correct value if with metadata"""
         d = dcmread(self.test_file)

pip install -e .
parse_log_pytest
requirements.txt
pytest
3.6
requirements/base.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
attrs==22.2.0
certifi==2021.5.30
importlib-metadata==4.8.3
iniconfig==1.1.1
packaging==21.3
pluggy==1.0.0
py==1.11.0
-e git+https://github.com/pydicom/pydicom.git@73767d0621fb86bf637b9dbaaa76b0557c3ef204#egg=pydicom
pyparsing==3.1.4
pytest==7.0.1
tomli==1.2.3
typing_extensions==4.1.1
zipp==3.6.0

name: pydicom
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2021.5.30=py36h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.3=he6710b0_2
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=21.2.2=py36h06a4308_0
  - python=3.6.13=h12debd9_1
  - readline=8.2=h5eee18b_0
  - setuptools=58.0.4=py36h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.37.1=pyhd3eb1b0_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - attrs==22.2.0
      - importlib-metadata==4.8.3
      - iniconfig==1.1.1
      - packaging==21.3
      - pluggy==1.0.0
      - py==1.11.0
      - pyparsing==3.1.4
      - pytest==7.0.1
      - tomli==1.2.3
      - typing-extensions==4.1.1
      - zipp==3.6.0
prefix: /opt/conda/envs/pydicom

pydicom/tests/test_dataset.py::TestFileDataset::test_pickle
pydicom/tests/test_dataset.py::TestDataset::test_attribute_error_in_property pydicom/tests/test_dataset.py::TestDataset::test_for_stray_raw_data_element pydicom/tests/test_dataset.py::TestDataset::test_attribute_error_in_property_correct_debug pydicom/tests/test_dataset.py::TestDataset::test_tag_exception_print pydicom/tests/test_dataset.py::TestDataset::test_tag_exception_walk pydicom/tests/test_dataset.py::TestDataset::test_set_new_data_element_by_name pydicom/tests/test_dataset.py::TestDataset::test_set_existing_data_element_by_name pydicom/tests/test_dataset.py::TestDataset::test_set_non_dicom pydicom/tests/test_dataset.py::TestDataset::test_membership pydicom/tests/test_dataset.py::TestDataset::test_contains pydicom/tests/test_dataset.py::TestDataset::test_clear pydicom/tests/test_dataset.py::TestDataset::test_pop pydicom/tests/test_dataset.py::TestDataset::test_pop_using_tuple pydicom/tests/test_dataset.py::TestDataset::test_pop_using_keyword pydicom/tests/test_dataset.py::TestDataset::test_popitem pydicom/tests/test_dataset.py::TestDataset::test_setdefault pydicom/tests/test_dataset.py::TestDataset::test_setdefault_tuple pydicom/tests/test_dataset.py::TestDataset::test_setdefault_use_value pydicom/tests/test_dataset.py::TestDataset::test_setdefault_keyword pydicom/tests/test_dataset.py::TestDataset::test_get_exists1 pydicom/tests/test_dataset.py::TestDataset::test_get_exists2 pydicom/tests/test_dataset.py::TestDataset::test_get_exists3 pydicom/tests/test_dataset.py::TestDataset::test_get_exists4 pydicom/tests/test_dataset.py::TestDataset::test_get_default1 pydicom/tests/test_dataset.py::TestDataset::test_get_default2 pydicom/tests/test_dataset.py::TestDataset::test_get_default3 pydicom/tests/test_dataset.py::TestDataset::test_get_default4 pydicom/tests/test_dataset.py::TestDataset::test_get_raises pydicom/tests/test_dataset.py::TestDataset::test_get_from_raw pydicom/tests/test_dataset.py::TestDataset::test__setitem__ pydicom/tests/test_dataset.py::TestDataset::test_matching_tags pydicom/tests/test_dataset.py::TestDataset::test_named_member_updated pydicom/tests/test_dataset.py::TestDataset::test_update pydicom/tests/test_dataset.py::TestDataset::test_dir_subclass pydicom/tests/test_dataset.py::TestDataset::test_dir pydicom/tests/test_dataset.py::TestDataset::test_dir_filter pydicom/tests/test_dataset.py::TestDataset::test_delete_dicom_attr pydicom/tests/test_dataset.py::TestDataset::test_delete_dicom_command_group_length pydicom/tests/test_dataset.py::TestDataset::test_delete_other_attr pydicom/tests/test_dataset.py::TestDataset::test_delete_dicom_attr_we_dont_have pydicom/tests/test_dataset.py::TestDataset::test_delete_item_long pydicom/tests/test_dataset.py::TestDataset::test_delete_item_tuple pydicom/tests/test_dataset.py::TestDataset::test_delete_non_existing_item pydicom/tests/test_dataset.py::TestDataset::test_equality_no_sequence pydicom/tests/test_dataset.py::TestDataset::test_equality_private pydicom/tests/test_dataset.py::TestDataset::test_equality_sequence pydicom/tests/test_dataset.py::TestDataset::test_equality_not_dataset pydicom/tests/test_dataset.py::TestDataset::test_equality_unknown pydicom/tests/test_dataset.py::TestDataset::test_equality_inheritance pydicom/tests/test_dataset.py::TestDataset::test_equality_elements pydicom/tests/test_dataset.py::TestDataset::test_inequality pydicom/tests/test_dataset.py::TestDataset::test_hash pydicom/tests/test_dataset.py::TestDataset::test_property pydicom/tests/test_dataset.py::TestDataset::test_add_repeater_elem_by_keyword pydicom/tests/test_dataset.py::TestDataset::test_setitem_slice_raises pydicom/tests/test_dataset.py::TestDataset::test_getitem_slice_raises pydicom/tests/test_dataset.py::TestDataset::test_empty_slice pydicom/tests/test_dataset.py::TestDataset::test_getitem_slice pydicom/tests/test_dataset.py::TestDataset::test_getitem_slice_ffff pydicom/tests/test_dataset.py::TestDataset::test_delitem_slice pydicom/tests/test_dataset.py::TestDataset::test_group_dataset pydicom/tests/test_dataset.py::TestDataset::test_get_item pydicom/tests/test_dataset.py::TestDataset::test_get_item_slice pydicom/tests/test_dataset.py::TestDataset::test_get_private_item pydicom/tests/test_dataset.py::TestDataset::test_private_block pydicom/tests/test_dataset.py::TestDataset::test_add_new_private_tag pydicom/tests/test_dataset.py::TestDataset::test_delete_private_tag pydicom/tests/test_dataset.py::TestDataset::test_private_creators pydicom/tests/test_dataset.py::TestDataset::test_is_original_encoding pydicom/tests/test_dataset.py::TestDataset::test_remove_private_tags pydicom/tests/test_dataset.py::TestDataset::test_data_element pydicom/tests/test_dataset.py::TestDataset::test_iterall pydicom/tests/test_dataset.py::TestDataset::test_save_as pydicom/tests/test_dataset.py::TestDataset::test_with pydicom/tests/test_dataset.py::TestDataset::test_exit_exception pydicom/tests/test_dataset.py::TestDataset::test_pixel_array_already_have pydicom/tests/test_dataset.py::TestDataset::test_pixel_array_id_changed pydicom/tests/test_dataset.py::TestDataset::test_pixel_array_unknown_syntax pydicom/tests/test_dataset.py::TestDataset::test_formatted_lines pydicom/tests/test_dataset.py::TestDataset::test_formatted_lines_known_uid pydicom/tests/test_dataset.py::TestDataset::test_set_convert_private_elem_from_raw pydicom/tests/test_dataset.py::TestDataset::test_top pydicom/tests/test_dataset.py::TestDataset::test_trait_names pydicom/tests/test_dataset.py::TestDataset::test_walk pydicom/tests/test_dataset.py::TestDataset::test_update_with_dataset pydicom/tests/test_dataset.py::TestDatasetElements::test_sequence_assignment pydicom/tests/test_dataset.py::TestDatasetElements::test_ensure_file_meta pydicom/tests/test_dataset.py::TestDatasetElements::test_fix_meta_info pydicom/tests/test_dataset.py::TestDatasetElements::test_validate_and_correct_file_meta pydicom/tests/test_dataset.py::TestFileDataset::test_equality_file_meta pydicom/tests/test_dataset.py::TestFileDataset::test_creation_with_container pydicom/tests/test_dataset.py::TestFileDataset::test_dataset_overrides_all_dict_attributes pydicom/tests/test_dataset.py::TestDatasetOverlayArray::test_no_possible pydicom/tests/test_dataset.py::TestDatasetOverlayArray::test_possible_not_available pydicom/tests/test_dataset.py::TestDatasetOverlayArray::test_possible_available pydicom/tests/test_dataset.py::TestDatasetOverlayArray::test_handler_raises
doc/release_notes/v1.4.0.rst pydicom/dataset.py
doc/release_notes/v1.4.0.rst pydicom/dataset.py