d3v-null / wp-api-python

A Python wrapper for the WooCommerce API.
MIT License
141 stars 34 forks source link

Updated to handle exceptions and unicode as Python 3.6 expects them t… #2

Closed mvartanyan closed 5 years ago

mvartanyan commented 6 years ago

apparently you guys are ahead of the last version in pypi. I made the code run well on Python 3.6.4 rather blindly, only where problems stood in my way. Hope you find the changes useful.

mvartanyan commented 6 years ago

Great, thanks @derwentx . Happy to test compatibility when changes hit pypi and report if they work for my application.

vincentwhales commented 6 years ago

Hey guys, any plans to merge this?

I am still seeing

Traceback (most recent call last):
  File "wp_api.py", line 20, in <module>
    wpapi.post('posts', { 'title': 'from', 'content': '<h1>API</h1>' })
  File "/Users/vng/.virtualenvs/prometheus/lib/python3.6/site-packages/wordpress/api.py", line 203, in post
    return self.__request("POST", endpoint, data, **kwargs)
  File "/Users/vng/.virtualenvs/prometheus/lib/python3.6/site-packages/wordpress/api.py", line 191, in __request
    self.request_post_mortem(response)
  File "/Users/vng/.virtualenvs/prometheus/lib/python3.6/site-packages/wordpress/api.py", line 105, in request_post_mortem
    unicode(response_json.get(key)) for key in ['code', 'message', 'data'] \
  File "/Users/vng/.virtualenvs/prometheus/lib/python3.6/site-packages/wordpress/api.py", line 106, in <listcomp>
    if key in response_json
NameError: name 'unicode' is not defined
mvartanyan commented 6 years ago

this is a question to @derwentx but the change to prevent this particular issue is available in the PR.

d3v-null commented 5 years ago

Hi all, I will work on ensuring that all of the features from this PR are added to the latest commit, then push an update to PyPi. I apologise for not seeing anything since my last comment.

it's actually embarrassing that these comments have been here for so long but I haven't received a single notification from GitHub about them (except maybe a blue dot next to the bell in the top right of the web interface which I rarely use)

Does anyone have any suggestions for how I can avoid missing these comments in the future? I have just about everything ticket in GitHub notification settings.

Thanks.

d3v-null commented 5 years ago

Hey all, I've included all the features of this PR but also made sure that it was Python2 and 3 compatible (which the original PR was not) and included tests that would previously fail because of the unicode bug. Feel free to test / verify. Thanks.