Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace urllib.urlopen to urllib.request.urlopen #12

Open
jhleee opened this issue Nov 30, 2017 · 2 comments
Open

Replace urllib.urlopen to urllib.request.urlopen #12

jhleee opened this issue Nov 30, 2017 · 2 comments

Comments

@jhleee
Copy link

jhleee commented Nov 30, 2017

python3 raise AttributeError.

Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1836, in __call__
    return self.wsgi_app(environ, start_response)
  File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1820, in wsgi_app
    response = self.make_response(self.handle_exception(e))
  File "/usr/local/lib/python3.5/dist-packages/flask_restful/__init__.py", line 270, in error_router
    return original_handler(e)
  File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1403, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python3.5/dist-packages/flask/_compat.py", line 32, in reraise
    raise value.with_traceback(tb)
  File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1817, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1477, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python3.5/dist-packages/flask_restful/__init__.py", line 270, in error_router
    return original_handler(e)
  File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1381, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python3.5/dist-packages/flask/_compat.py", line 32, in reraise
    raise value.with_traceback(tb)
  File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1475, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1461, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/usr/local/lib/python3.5/dist-packages/flask_restful/__init__.py", line 462, in wrapper
    resp = resource(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/flask/views.py", line 84, in view
    return self.dispatch_request(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/flask_restful/__init__.py", line 572, in dispatch_request
    resp = meth(*args, **kwargs)
  File "/media/sf_workspace/python/flask/codebot_kakao/app.py", line 66, in post
    url = save_to_pastebin(code, format="python")
  File "/media/sf_workspace/python/flask/codebot_kakao/app.py", line 28, in save_to_pastebin
    paste_private = 'unlisted')
  File "/usr/local/lib/python3.5/dist-packages/pastebin.py", line 679, in paste
    request_string = urllib.urlopen(self._api_url, urllib.urlencode(argv))
AttributeError: module 'urllib' has no attribute 'urlopen'

It should be replace to urllib.request.urlopen

@csm10495
Copy link

csm10495 commented Dec 6, 2018

There's a bit more too here, we'll also run into issues with urlencode(), etc. Using the six package would be a better way to go about this. @Morrolan are you open to pull requests to make this work on both py2 and py3?

howiezhao added a commit to howiezhao/PastebinAPI that referenced this issue Mar 17, 2021
@bitsnaps
Copy link

Got the same issue on colab, looks like pip package is outdated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants