Skip to content

401 Unauthorized on Python 3.3 #1

@jaraco

Description

@jaraco

I tested the library on Python 3.4, and it seems to be working. I then deployed it on a system running Python 3.3 and I get 401 Unauthorized errors. Consider this test script:

import sys
short_ver = '{vi[0]}.{vi[1]}'.format(vi=sys.version_info)

sys.path.insert(0, './wordnik_py3-2.1.2-py{vi}.egg'.format(vi=short_ver))

import wordnik.WordApi
import wordnik.swagger

key = 'elided'
client = wordnik.swagger.ApiClient(key, 'http://api.wordnik.com/v4')
words = wordnik.WordApi.WordApi(client)
words.getDefinitions('dachshund', limit=1)

If I have the wordnik-py3 2.1.2 eggs for Python 3.3 and Python 3.4 in the current directory, I can then run the above script for each. On Python 3.4, it passes without error. On Python 3.3, I get this traceback:

Traceback (most recent call last):
  File ".\test-wn.py", line 12, in <module>
    words.getDefinitions('dachshund', limit=1)
  File "./wordnik_py3-2.1.2-py3.3.egg\wordnik\WordApi.py", line 182, in getDefinitions
    postData, headerParams)
  File "./wordnik_py3-2.1.2-py3.3.egg\wordnik\swagger.py", line 73, in callAPI
    request = urllib.request.urlopen(requestParams)
  File "C:\Program Files\Python33\lib\urllib\request.py", line 156, in urlopen
    return opener.open(url, data, timeout)
  File "C:\Program Files\Python33\lib\urllib\request.py", line 475, in open
    response = meth(req, response)
  File "C:\Program Files\Python33\lib\urllib\request.py", line 587, in http_response
    'http', request, response, code, msg, hdrs)
  File "C:\Program Files\Python33\lib\urllib\request.py", line 513, in error
    return self._call_chain(*args)
  File "C:\Program Files\Python33\lib\urllib\request.py", line 447, in _call_chain
    result = func(*args)
  File "C:\Program Files\Python33\lib\urllib\request.py", line 595, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 401: Unauthorized

I'm using the exact same script, so the difference appears to be in how WordNik assembles the HTTP request on Python 3.3, somehow triggering the 401.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions