Repository: sagemath/sage

Issue:
Cannot detect whether a sequence from the oeis is dead without warning
### Steps To Reproduce

In a fresh session,
```
sage: s = oeis(17)
sage: s.is_dead()
/home/martin/sage/src/sage/databases/oeis.py:1153: RuntimeWarning: This sequence is dead: "A000017: Erroneous version of A032522."
  warn('This sequence is dead: "{}: {}"'.format(self.id(), self.name()), RuntimeWarning)
True
```

### Expected Behavior

It should just return the result, without triggering the warning.

### Actual Behavior

A warning is triggered, which is annoying when processing many sequences.

### Additional Information

The reason is that `OEISSequence._field` issues a warning when the sequence is dead, and this cannot be bypassed.

I see two possible solutions:
* have a keyword `warn` for `_field(self, warn=True)` and, in `is_dead`, do `"dead" in self._field('K', warn=False)[0]`.
* check the `raw_entry` in `is_dead` directly, e.g., `["dead" in l[11:] for l in s.raw_entry().splitlines() if l[1] == "K"]`

### Environment

```markdown
irrelevant.
```


### Checklist

- [X] I have searched the existing issues for a bug report that matches the one I want to file, without success.
- [X] I have read the documentation and troubleshoot guide


Discussion:

Resolving patch:
diff --git a/src/sage/databases/oeis.py b/src/sage/databases/oeis.py
--- a/src/sage/databases/oeis.py
+++ b/src/sage/databases/oeis.py
@@ -722,7 +722,7 @@ def online_update(self):
         except AttributeError:
             pass
 
-    def _field(self, key):
+    def _field(self, key, warn=True):
         r"""
         Return the ``key`` field of the entry of ``self``.
 
@@ -741,7 +741,7 @@ def _field(self, key):
             for line in self.raw_entry().splitlines():
                 fields[line[1]].append(line[11:])
             self._fields = fields
-            self.is_dead(warn_only=True)
+            self.is_dead(warn_only=warn)
             return self._fields[key]
 
     def id(self, format='A'):
@@ -959,7 +959,7 @@ def author(self):
         """
         return self._field('A')[0]
 
-    def keywords(self):
+    def keywords(self, warn=True):
         r"""
         Return the keywords associated to the sequence ``self``.
 
@@ -985,7 +985,7 @@ def keywords(self):
             sage: s.keywords()
             ('nonn', 'hard')
         """
-        return tuple(self._field('K')[0].split(','))
+        return tuple(self._field('K', warn=warn)[0].split(','))
 
     def natural_object(self):
         r"""
@@ -1108,8 +1108,8 @@ def is_dead(self, warn_only=False):
 
         EXAMPLES:
 
-        A warn_only test is triggered as soon as some information on the
-        sequence is queried::
+        A warning is triggered if any field of a dead sequence is accessed,
+        unless :meth:`is_dead` is called before::
 
             sage: s = oeis(17)
             sage: s                                 # optional -- internet
@@ -1138,11 +1138,11 @@ def is_dead(self, warn_only=False):
             True
         """
         if warn_only:
-            if 'dead' in self.keywords():
+            if 'dead' in self.keywords(warn_only):
                 from warnings import warn
                 warn('This sequence is dead: "{}: {}"'.format(self.id(), self.name()), RuntimeWarning)
         else:
-            return 'dead' in self.keywords()
+            return 'dead' in self.keywords(warn_only)
 
     def is_finite(self):
         r"""
@@ -2010,6 +2010,7 @@ def test_compile_sage_code(self):
             True
         """
         if self.is_dead():
+            self.is_dead(warn_only=True)
             return True
         filt = self.programs(language='sage')
         if filt:


Test patch: