Repository: goodmami/wn

Issue:
If you try to loop through senses first, hypernym_paths() hangs
Hi,

if you try to loop through senses, then try to find hypernym paths, the code hangs.   Looping through synsets is fine!

For example, the code below will print the path for the synset in the first loop, but hang in the second loop. 


```
##
## MWP
##

import wn
en = wn.Wordnet('omw-en:1.4')

organism = en.synsets(ili='i35563')[0] #beast

for ss in en.synsets(pos='n'):
    if ss == organism:
        print(ss.hypernym_paths())
                
for s in en.senses(pos='n'):
    ss == s.synset()
    if ss == organism:
        print(ss.hypernym_paths())
```


Discussion:

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 31499b6..4a066dc 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,7 +13,9 @@
 * `wn.download()` no longer uses Python features unavailable in 3.7
   when recovering from download errors
 * `Sense.synset()` now creates a `Synset` properly linked to the same
-  `Wordnet` object ([#168])
+  `Wordnet` object ([#157], [#168])
+* `Sense.word()` now creates a `Word` properly linked to the same
+  `Wordnet` object ([#157])
 
 
 ## [v0.9.1]
@@ -585,4 +587,5 @@ abandoned, but this is an entirely new codebase.
 [#154]: https://github.com/goodmami/wn/issues/154
 [#155]: https://github.com/goodmami/wn/issues/155
 [#156]: https://github.com/goodmami/wn/issues/156
+[#157]: https://github.com/goodmami/wn/issues/157
 [#168]: https://github.com/goodmami/wn/issues/168
diff --git a/wn/_core.py b/wn/_core.py
index e74b928..0d89f42 100644
--- a/wn/_core.py
+++ b/wn/_core.py
@@ -891,7 +891,7 @@ class Sense(_Relatable):
             Word('pwn-spigot-n')
 
         """
-        return word(id=self._entry_id)
+        return self._wordnet.word(id=self._entry_id)
 
     def synset(self) -> Synset:
         """Return the synset of the sense.


Test patch:
diff --git a/tests/secondary_query_test.py b/tests/secondary_query_test.py
index 9b97187..56d91b0 100644
--- a/tests/secondary_query_test.py
+++ b/tests/secondary_query_test.py
@@ -38,6 +38,16 @@ def test_sense_synset():
             == wn.synset('test-es-0001-n'))
 
 
+@pytest.mark.usefixtures('mini_db')
+def test_sense_issue_157():
+    # https://github.com/goodmami/wn/issues/157
+    sense = wn.sense('test-en-information-n-0001-01')
+    # This test uses non-public members, which is not ideal, but there
+    # is currently no better alternative.
+    assert sense._wordnet is sense.word()._wordnet
+    assert sense._wordnet is sense.synset()._wordnet
+
+
 @pytest.mark.usefixtures('mini_db')
 def test_sense_examples():
     assert wn.sense('test-en-information-n-0001-01').examples() == []