diff --git a/Lib/glyphsLib/builder/features.py b/Lib/glyphsLib/builder/features.py
index a3295dd9..f8d3f1c2 100644
--- a/Lib/glyphsLib/builder/features.py
+++ b/Lib/glyphsLib/builder/features.py
@@ -393,7 +393,7 @@ class FeaDocument:
                 previous_in_block = None
             previous = st
             if hasattr(st, "statements"):
-                previous_in_block = st.statements[-1]
+                previous_in_block = st.statements[-1] if st.statements else None
 
     WHITESPACE_RE = re.compile("\\s")
     WHITESPACE_OR_NAME_RE = re.compile("\\w|\\s")
diff --git a/Lib/glyphsLib/classes.py b/Lib/glyphsLib/classes.py
index 8b1f2f84..4e89f5c4 100755
--- a/Lib/glyphsLib/classes.py
+++ b/Lib/glyphsLib/classes.py
@@ -13,6 +13,7 @@
 # limitations under the License.
 
 
+import copy
 import re
 import math
 import inspect
@@ -314,7 +315,7 @@ class GSBase:
                     # instead of None when no image
                     value = []
                 elif key in self._defaultsForName:
-                    value = self._defaultsForName.get(key)
+                    value = copy.deepcopy(self._defaultsForName.get(key))
                 else:
                     value = klass()
                 key = self._wrapperKeysTranslate.get(key, key)
diff --git a/requirements-dev.in b/requirements-dev.in
index 880b40b9..b7965080 100644
--- a/requirements-dev.in
+++ b/requirements-dev.in
@@ -1,5 +1,4 @@
 coverage
 pytest>=2.8
-pytest-randomly
 ufoNormalizer>=0.3.2
 xmldiff>=2.2
diff --git a/requirements-dev.txt b/requirements-dev.txt
index 4a66a1ed..72de3cf9 100644
--- a/requirements-dev.txt
+++ b/requirements-dev.txt
@@ -5,23 +5,21 @@
 #    pip-compile requirements-dev.in
 #
 atomicwrites==1.3.0       # via pytest
-attrs==19.3.0             # via pytest
+attrs==19.1.0             # via packaging, pytest
 coverage==4.5.4
-entrypoints==0.3          # via pytest-randomly
-importlib-metadata==0.23  # via pluggy, pytest
+importlib-metadata==0.22  # via pluggy, pytest
 lxml==4.4.1               # via xmldiff
 more-itertools==7.2.0     # via pytest, zipp
-packaging==19.2           # via pytest
+packaging==19.1           # via pytest
 pluggy==0.13.0            # via pytest
 py==1.8.0                 # via pytest
 pyparsing==2.4.2          # via packaging
-pytest-randomly==3.1.0
-pytest==5.2.2
+pytest==5.1.2
 six==1.12.0               # via packaging, xmldiff
 ufonormalizer==0.3.6
 wcwidth==0.1.7            # via pytest
-xmldiff==2.4
+xmldiff==2.3
 zipp==0.6.0               # via importlib-metadata
 
 # The following packages are considered to be unsafe in a requirements file:
-# setuptools==41.6.0        # via xmldiff
+# setuptools==41.2.0        # via xmldiff

can't roundtrip glyphs2ufo and ufo2glyphs for a particular Rubik-Italic.glyphs file
When I run glyphs2ufo on this file, and then run ufo2glyphs again without changing anything I get an error (see below). Usually this process works without issue, but just one this one file I have a problem. For whatever reason this only happens on the Italic and not on the Roman. I've hit this error while working on making variable font versions of the family for Google Fonts and Dave and Marc said I should report it here, since it looks like a bug. Thanks! 

Full traceback is:
~~~
Traceback (most recent call last):
  File "/Users/cjdunn/env_gtools/bin/ufo2glyphs", line 10, in <module>
    sys.exit(_ufo2glyphs_entry_point())
  File "/Users/cjdunn/env_gtools/lib/python3.7/site-packages/glyphsLib/cli.py", line 268, in _ufo2glyphs_entry_point
    return main(args)
  File "/Users/cjdunn/env_gtools/lib/python3.7/site-packages/glyphsLib/cli.py", line 169, in main
    return options.func(options)
  File "/Users/cjdunn/env_gtools/lib/python3.7/site-packages/glyphsLib/cli.py", line 244, in ufo2glyphs
    object_to_read, minimize_ufo_diffs=options.no_preserve_glyphsapp_metadata
  File "/Users/cjdunn/env_gtools/lib/python3.7/site-packages/glyphsLib/builder/__init__.py", line 139, in to_glyphs
    return builder.font
  File "/Users/cjdunn/env_gtools/lib/python3.7/site-packages/glyphsLib/builder/builders.py", line 654, in font
    self.to_glyphs_features()
  File "/Users/cjdunn/env_gtools/lib/python3.7/site-packages/glyphsLib/builder/features.py", line 274, in to_glyphs_features
    glyphs_module=self.glyphs_module,
  File "/Users/cjdunn/env_gtools/lib/python3.7/site-packages/glyphsLib/builder/features.py", line 287, in _to_glyphs_features
    document = FeaDocument(features_text, glyph_names)
  File "/Users/cjdunn/env_gtools/lib/python3.7/site-packages/glyphsLib/builder/features.py", line 342, in __init__
    self._build_end_locations()
  File "/Users/cjdunn/env_gtools/lib/python3.7/site-packages/glyphsLib/builder/features.py", line 372, in _build_end_locations
    self._build_end_locations_rec(self._doc)
  File "/Users/cjdunn/env_gtools/lib/python3.7/site-packages/glyphsLib/builder/features.py", line 396, in _build_end_locations_rec
    previous_in_block = st.statements[-1]
IndexError: list index out of range

~~~

Here's the file: 
[Rubik_Italic.glyphs.zip](https://github.com/googlefonts/glyphsLib/files/3799060/Rubik_Italic.glyphs.zip)


diff --git a/tests/builder/features_test.py b/tests/builder/features_test.py
index edb3474f..67c549b8 100644
--- a/tests/builder/features_test.py
+++ b/tests/builder/features_test.py
@@ -462,3 +462,26 @@ def test_groups_remain_at_top(tmpdir):
 
     fea_rt = rtufo.features.text
     assert fea_rt.index("@FIG_DFLT") < fea_rt.index("lookup") < fea_rt.index("feature")
+
+
+def test_roundtrip_empty_feature():
+    # https://github.com/googlefonts/glyphsLib/issues/562
+    font = to_glyphs([defcon.Font()])
+    feature = classes.GSFeature(name="dlig")
+    feature.code = ""
+    font.features.append(feature)
+
+    ufo, = to_ufos(font)
+    assert ufo.features.text == dedent(
+        """\
+        feature dlig {
+
+        } dlig;
+    """
+    )
+
+    font_r = to_glyphs([ufo])
+    assert len(font_r.features) == 1
+    feature_r = font_r.features[0]
+    assert feature_r.name == "dlig"
+    assert feature_r.code == ""

pip install -e .[dev]
parse_log_pytest
requirements.txt
pytest pytest-asyncio defcon
apt-get update apt-get install -y gcc
3.9
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
appdirs==1.4.3
defcon==0.6.0
exceptiongroup==1.2.2
fonttools==3.40.0
fs==2.4.11
-e git+https://github.com/googlefonts/glyphsLib.git@5bb9840f2203c0e289b54369b26963cc039a73fb#egg=glyphsLib
iniconfig==2.1.0
packaging==24.2
pluggy==1.5.0
pytest==8.3.5
pytest-asyncio==0.26.0
pytz==2019.2
six==1.12.0
tomli==2.2.1
typing_extensions==4.13.0

name: glyphsLib
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
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - 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=3.0.16=h5eee18b_0
  - pip=25.0=py39h06a4308_0
  - python=3.9.21=he870216_1
  - readline=8.2=h5eee18b_0
  - setuptools=75.8.0=py39h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tzdata=2025a=h04d1e81_0
  - wheel=0.45.1=py39h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - appdirs==1.4.3
      - defcon==0.6.0
      - exceptiongroup==1.2.2
      - fonttools==3.40.0
      - fs==2.4.11
      - glyphslib==5.0.2.dev7+g5bb9840f
      - iniconfig==2.1.0
      - packaging==24.2
      - pluggy==1.5.0
      - pytest==8.3.5
      - pytest-asyncio==0.26.0
      - pytz==2019.2
      - six==1.12.0
      - tomli==2.2.1
      - typing-extensions==4.13.0
prefix: /opt/conda/envs/glyphsLib

tests/builder/features_test.py::test_roundtrip_empty_feature
tests/builder/features_test.py::test_blank tests/builder/features_test.py::test_comment tests/builder/features_test.py::test_languagesystems tests/builder/features_test.py::test_classes tests/builder/features_test.py::test_class_synonym tests/builder/features_test.py::test_include tests/builder/features_test.py::test_include_no_semicolon tests/builder/features_test.py::test_standalone_lookup tests/builder/features_test.py::test_feature tests/builder/features_test.py::test_different_features_in_different_UFOS tests/builder/features_test.py::test_roundtrip_disabled_feature tests/builder/features_test.py::test_roundtrip_automatic_feature tests/builder/features_test.py::test_roundtrip_feature_prefix_with_only_a_comment tests/builder/features_test.py::test_roundtrip_existing_GDEF tests/builder/features_test.py::test_generate_GDEF_already_exists tests/builder/features_test.py::test_groups_remain_at_top
Lib/glyphsLib/builder/features.py requirements-dev.txt requirements-dev.in Lib/glyphsLib/classes.py
Lib/glyphsLib/builder/features.py requirements-dev.txt requirements-dev.in Lib/glyphsLib/classes.py