diff --git a/omegaconf/config.py b/omegaconf/config.py
index 0a8995d..a1b3f14 100644
--- a/omegaconf/config.py
+++ b/omegaconf/config.py
@@ -83,6 +83,13 @@ class Config(object):
         assert value is None or isinstance(value, bool)
         self.__dict__['flags'][flag] = value
 
+    def _get_node_flag(self, flag):
+        """
+        :param flag: flag to inspect
+        :return: the state of the flag on this node.
+        """
+        return self.__dict__['flags'][flag]
+
     def _get_flag(self, flag):
         """
         Returns True if this config node flag is set
diff --git a/omegaconf/omegaconf.py b/omegaconf/omegaconf.py
index 03e908b..df3a92b 100644
--- a/omegaconf/omegaconf.py
+++ b/omegaconf/omegaconf.py
@@ -228,7 +228,8 @@ def flag_override(config, name, value):
 # noinspection PyProtectedMember
 @contextmanager
 def read_write(config):
-    prev_state = OmegaConf.is_readonly(config)
+    # noinspection PyProtectedMember
+    prev_state = config._get_node_flag("readonly")
     try:
         OmegaConf.set_readonly(config, False)
         yield config
@@ -238,7 +239,8 @@ def read_write(config):
 
 @contextmanager
 def open_dict(config):
-    prev_state = OmegaConf.is_struct(config)
+    # noinspection PyProtectedMember
+    prev_state = config._get_node_flag("struct")
     try:
         OmegaConf.set_struct(config, False)
         yield config

diff --git a/tests/test_base_config.py b/tests/test_base_config.py
index 713ff52..b7112ed 100644
--- a/tests/test_base_config.py
+++ b/tests/test_base_config.py
@@ -275,3 +275,19 @@ def test_struct_override(src, func, expectation):
     with does_not_raise():
         with open_dict(c):
             func(c)
+
+
+@pytest.mark.parametrize("flag_name,ctx", [("struct", open_dict), ("readonly", read_write)])
+def test_open_dict_restore(flag_name, ctx):
+    """
+    Tests that internal flags are restored properly when applying context on a child node
+    """
+    cfg = OmegaConf.create({"foo": {"bar": 10}})
+    cfg._set_flag(flag_name, True)
+    assert cfg._get_node_flag(flag_name)
+    assert not cfg.foo._get_node_flag(flag_name)
+    with ctx(cfg.foo):
+        cfg.foo.bar = 20
+    assert cfg._get_node_flag(flag_name)
+    assert not cfg.foo._get_node_flag(flag_name)
+

open_dict change value to the inherited value
for a nested config:
```yaml
foo:
  bar:
    baz: 10
```
if foo is struct, and we do
```python
with open_dict(cfg.foo.bar):
   bar.baz = 20
```

the struct flag of foo.bar would be changed to True.
tests/test_base_config.py::test_open_dict_restore[struct-open_dict] tests/test_base_config.py::test_open_dict_restore[readonly-read_write]
tests/test_base_config.py::test_set_value[input_0-foo-10-expected0] tests/test_base_config.py::test_set_value[input_1-foo-value1-expected1] tests/test_base_config.py::test_set_value[input_2-foo-value2-expected2] tests/test_base_config.py::test_set_value[input_3-foo-value3-expected3] tests/test_base_config.py::test_set_value[input_4-0-10-expected4] tests/test_base_config.py::test_set_value[input_5-1-10-expected5] tests/test_base_config.py::test_set_value[input_6-1-value6-expected6] tests/test_base_config.py::test_set_value[input_7-1-value7-expected7] tests/test_base_config.py::test_set_value[input_8-1-value8-expected8] tests/test_base_config.py::test_set_value_validation_fail[input_0-foo-str] tests/test_base_config.py::test_set_value_validation_fail[input_1-1-str] tests/test_base_config.py::test_to_container_returns_primitives[input_0] tests/test_base_config.py::test_to_container_returns_primitives[input_1] tests/test_base_config.py::test_to_container_returns_primitives[input_2] tests/test_base_config.py::test_to_container_returns_primitives[input_3] tests/test_base_config.py::test_to_container_returns_primitives[input_4] tests/test_base_config.py::test_empty[input_0-True] tests/test_base_config.py::test_empty[input_1-True] tests/test_base_config.py::test_empty[input_2-False] tests/test_base_config.py::test_empty[input_3-False] tests/test_base_config.py::test_repr[input_0] tests/test_base_config.py::test_repr[input_1] tests/test_base_config.py::test_repr[input_2] tests/test_base_config.py::test_repr[input_3] tests/test_base_config.py::test_repr[input_4] tests/test_base_config.py::test_repr[input_5] tests/test_base_config.py::test_repr[input_6] tests/test_base_config.py::test_str[input_0] tests/test_base_config.py::test_str[input_1] tests/test_base_config.py::test_str[input_2] tests/test_base_config.py::test_str[input_3] tests/test_base_config.py::test_str[input_4] tests/test_base_config.py::test_str[input_5] tests/test_base_config.py::test_str[input_6] tests/test_base_config.py::test_flag_dict[readonly] tests/test_base_config.py::test_flag_dict[struct] tests/test_base_config.py::test_freeze_nested_dict[readonly] tests/test_base_config.py::test_freeze_nested_dict[struct] tests/test_base_config.py::test_deepcopy[src0] tests/test_base_config.py::test_deepcopy[src1] tests/test_base_config.py::test_deepcopy[src2] tests/test_base_config.py::test_deepcopy[src3] tests/test_base_config.py::test_deepcopy_readonly[src0] tests/test_base_config.py::test_deepcopy_readonly[src1] tests/test_base_config.py::test_deepcopy_readonly[src2] tests/test_base_config.py::test_deepcopy_readonly[src3] tests/test_base_config.py::test_deepcopy_struct[src0] tests/test_base_config.py::test_deepcopy_struct[src1] tests/test_base_config.py::test_deepcopy_struct[src2] tests/test_base_config.py::test_deepcopy_struct[src3] tests/test_base_config.py::test_deepcopy_after_del tests/test_base_config.py::test_deepcopy_with_interpolation tests/test_base_config.py::test_deepcopy_and_merge_and_flags tests/test_base_config.py::test_flag_override[src0-struct-False-<lambda>-expectation0] tests/test_base_config.py::test_flag_override[src1-readonly-False-<lambda>-expectation1] tests/test_base_config.py::test_read_write_override[src0-<lambda>-expectation0] tests/test_base_config.py::test_read_write_override[src1-<lambda>-expectation1] tests/test_base_config.py::test_tokenize_with_escapes[dog,cat-tokenized0] tests/test_base_config.py::test_tokenize_with_escapes[dog\\,cat\\ tests/test_base_config.py::test_tokenize_with_escapes[dog,\\ tests/test_base_config.py::test_tokenize_with_escapes[\\ tests/test_base_config.py::test_tokenize_with_escapes[dog, tests/test_base_config.py::test_tokenize_with_escapes[whitespace\\ tests/test_base_config.py::test_tokenize_with_escapes[None-tokenized8] tests/test_base_config.py::test_tokenize_with_escapes[-tokenized9] tests/test_base_config.py::test_tokenize_with_escapes[no tests/test_base_config.py::test_struct_override[src0-<lambda>-expectation0]