diff --git a/kwant/physics/selfenergy.py b/kwant/physics/selfenergy.py
index a44f82f17178a0e0cfa3a85c26f5b7d11ed996db..5c0814c9b89f0d4bba60516051e15cecc4834646 100644
--- a/kwant/physics/selfenergy.py
+++ b/kwant/physics/selfenergy.py
@@ -457,9 +457,9 @@ def unified_eigenproblem(h_onslice, h_hop, tol):
             propselect = (np.abs(np.abs(alpha) - np.abs(beta)) <
                           eps * tol * np.abs(beta))
 
-            invalid_warning_setting = np.seterr(invalid='ignore')['invalid']
+            warning_settings = np.seterr(divide='ignore', invalid='ignore')
             ev = alpha/beta
-            np.seterr(invalid=invalid_warning_setting)
+            np.seterr(**warning_settings)
             # Note: the division is OK here, as we later only access
             #       eigenvalues close to the unit circle
 
diff --git a/kwant/physics/tests/test_selfenergy.py b/kwant/physics/tests/test_selfenergy.py
index 326beb635b3a533624f5f37135ac572bcc609845..79059e3ac4d82a9d1c94a360c73666466b9495c4 100644
--- a/kwant/physics/tests/test_selfenergy.py
+++ b/kwant/physics/tests/test_selfenergy.py
@@ -222,6 +222,14 @@ def test_singular_degenerate_with_crossing():
     assert_almost_equal(g,
                         se.self_energy(h_onslice, h_hop))
 
+def test_singular_h_and_t():
+    h = 0.1 * np.identity(6)
+    t = np.eye(6, 6, 4)
+    sigma = se.self_energy(h, t)
+    sigma_should_be = np.zeros((6,6))
+    sigma_should_be[4, 4] = sigma_should_be[5, 5] = -10
+    assert_almost_equal(se.self_energy(h, t), sigma_should_be)
+
 def test_modes():
     h, t = .3, .7
     vecs, vecslinv, nrpop, svd = se.modes(np.mat(h), np.mat(t))