Hi John,
Thanks for putting wordhoard together! I keep running into the following error, though not all the time:
TypeError: object of type 'NoneType' has no len()
(details below)
What I've been doing is just to feed in to wordhoard a file with a list of unique words on it, in order to find antonyms, and then I write the dictionary object out to a second file.
Here's where it works correctly:
antonyms were found for the word: bassoon [Small note -- should be 'No' antonyms I think]
Please verify that the word is spelled correctly.
None
antonyms were found for the word: bassist [Again, I think it should be 'No' antonyms]
Please verify that the word is spelled correctly.
I tried writing code like this:
Check if the result is not None before processing
if wordhoard_antonym_results is not None:
with open(output_filename, 'a') as outfile:
outfile.write(json.dumps(wordhoard_antonym_results) + '\n')
But that didn't work, I suspect because the failure is happening in code earlier than when my code runs.
At any rate, here is the error, which for some reason is now occurring all the time. Not sure if this is because my ipaddress is being blocked, or what:
mown
INFO:wordhoard.antonyms:Thesaurus.com had no antonym reference for the word mown
ERROR:wordhoard.utilities.request_html:A RequestException has occurred when requesting https://www.wordhippo.com/what-is/the-opposite-of/mown.html
ERROR:wordhoard.utilities.request_html: File "/usr/local/lib/python3.9/dist-packages/wordhoard/utilities/request_html.py", line 102, in get_website_html
response = self._requests_retry_session().get(self._url_to_scrape,
File "/usr/local/lib/python3.9/dist-packages/requests/sessions.py", line 600, in get
return self.request("GET", url, **kwargs)
File "/usr/local/lib/python3.9/dist-packages/requests/sessions.py", line 587, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python3.9/dist-packages/requests/sessions.py", line 701, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python3.9/dist-packages/requests/adapters.py", line 556, in send
raise RetryError(e, request=request)
ERROR:root:Internal Python error in the inspect module.
Below is the traceback from this internal error.
A RequestException has occurred.
Please review the WordHoard logs for additional information.
Traceback (most recent call last):
File "/usr/local/lib/python3.9/dist-packages/requests/adapters.py", line 489, in send
resp = conn.urlopen(
File "/usr/local/lib/python3.9/dist-packages/urllib3/connectionpool.py", line 878, in urlopen
return self.urlopen(
File "/usr/local/lib/python3.9/dist-packages/urllib3/connectionpool.py", line 878, in urlopen
return self.urlopen(
File "/usr/local/lib/python3.9/dist-packages/urllib3/connectionpool.py", line 878, in urlopen
return self.urlopen(
[Previous line repeated 2 more times]
File "/usr/local/lib/python3.9/dist-packages/urllib3/connectionpool.py", line 868, in urlopen
retries = retries.increment(method, url, response=response, _pool=self)
File "/usr/local/lib/python3.9/dist-packages/urllib3/util/retry.py", line 592, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='www.wordhippo.com', port=443): Max retries exceeded with url: /what-is/the-opposite-of/mown.html (Caused by ResponseError('too many 503 error responses'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/dist-packages/wordhoard/utilities/request_html.py", line 102, in get_website_html
response = self._requests_retry_session().get(self._url_to_scrape,
File "/usr/local/lib/python3.9/dist-packages/requests/sessions.py", line 600, in get
return self.request("GET", url, **kwargs)
File "/usr/local/lib/python3.9/dist-packages/requests/sessions.py", line 587, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python3.9/dist-packages/requests/sessions.py", line 701, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python3.9/dist-packages/requests/adapters.py", line 556, in send
raise RetryError(e, request=request)
requests.exceptions.RetryError: HTTPSConnectionPool(host='www.wordhippo.com', port=443): Max retries exceeded with url: /what-is/the-opposite-of/mown.html (Caused by ResponseError('too many 503 error responses'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/dist-packages/IPython/core/interactiveshell.py", line 3553, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "", line 16, in <cell line: 11>
wordhoard_antonym_results = Antonyms(search_string=line.strip(), output_format='dictionary').find_antonyms()
File "/usr/local/lib/python3.9/dist-packages/backoff/_sync.py", line 105, in retry
ret = target(*args, **kwargs)
File "/usr/local/lib/python3.9/dist-packages/ratelimit/decorators.py", line 147, in wrapper
return func(*args, **kargs)
File "/usr/local/lib/python3.9/dist-packages/wordhoard/antonyms.py", line 227, in find_antonyms
query_results = self._run_query_tasks_in_parallel()
File "/usr/local/lib/python3.9/dist-packages/wordhoard/antonyms.py", line 180, in _run_query_tasks_in_parallel
finished_tasks.append(finished_task.result())
File "/usr/lib/python3.9/concurrent/futures/_base.py", line 439, in result
return self.__get_result()
File "/usr/lib/python3.9/concurrent/futures/_base.py", line 391, in __get_result
raise self._exception
File "/usr/lib/python3.9/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/local/lib/python3.9/dist-packages/wordhoard/antonyms.py", line 353, in _query_wordhippo
response = self._request_http_response(f'https://www.wordhippo.com/what-is/the-opposite-of/{self._word}.html')
File "/usr/local/lib/python3.9/dist-packages/wordhoard/antonyms.py", line 151, in _request_http_response
response = Query(url).get_website_html()
File "/usr/local/lib/python3.9/dist-packages/wordhoard/utilities/request_html.py", line 254, in get_website_html
sys.exit(1)
SystemExit: 1
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/dist-packages/IPython/core/ultratb.py", line 1101, in get_records
return _fixed_getinnerframes(etb, number_of_lines_of_context, tb_offset)
File "/usr/local/lib/python3.9/dist-packages/IPython/core/ultratb.py", line 248, in wrapped
return f(*args, **kwargs)
File "/usr/local/lib/python3.9/dist-packages/IPython/core/ultratb.py", line 281, in _fixed_getinnerframes
records = fix_frame_records_filenames(inspect.getinnerframes(etb, context))
File "/usr/lib/python3.9/inspect.py", line 1543, in getinnerframes
frameinfo = (tb.tb_frame,) + getframeinfo(tb, context)
AttributeError: 'tuple' object has no attribute 'tb_frame'
MaxRetryError Traceback (most recent call last)
/usr/local/lib/python3.9/dist-packages/requests/adapters.py in send(self, request, stream, timeout, verify, cert, proxies)
488 if not chunked:
--> 489 resp = conn.urlopen(
490 method=request.method,
30 frames
MaxRetryError: HTTPSConnectionPool(host='www.wordhippo.com', port=443): Max retries exceeded with url: /what-is/the-opposite-of/mown.html (Caused by ResponseError('too many 503 error responses'))
During handling of the above exception, another exception occurred:
RetryError Traceback (most recent call last)
RetryError: HTTPSConnectionPool(host='www.wordhippo.com', port=443): Max retries exceeded with url: /what-is/the-opposite-of/mown.html (Caused by ResponseError('too many 503 error responses'))
During handling of the above exception, another exception occurred:
SystemExit Traceback (most recent call last)
[... skipping hidden 1 frame]
SystemExit: 1
During handling of the above exception, another exception occurred:
TypeError Traceback (most recent call last)
[... skipping hidden 1 frame]
/usr/local/lib/python3.9/dist-packages/IPython/core/ultratb.py in find_recursion(etype, value, records)
380 # first frame (from in to out) that looks different.
381 if not is_recursion_error(etype, value, records):
--> 382 return len(records), 0
383
384 # Select filename, lineno, func_name to track frames with
TypeError: object of type 'NoneType' has no len()