question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Deprecate urllib3.request module

See original GitHub issue

Context

After adding the top-level request() method, We have a function named request in urllib3.__init__.py and a module named request(urllib3.request.py). It changes the from request import request behavior.

  • Old behavior: importing request module.
  • New behavior: importing request function.

Possible Solution

  • We could rename the request module to urllib3.request_methods and add a deprecated module urllib3.request.
  • We have to raise an AttributeError when accessing request.RequestMethods

Contribution

Would you be willing to submit a PR? (Help can be provided if you need assistance submitting a PR)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

7reactions
atodorovcommented, Jun 24, 2021

Probably it’s the same issue but following the instructions from the website:

>>> import urllib3
>>> resp = urllib3.request("GET", "https://httpbin.org/robots.txt")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'module' object is not callable

Not a good first-user experience. At least update the documentation.

2reactions
pquentincommented, Jun 17, 2021

This is all very true, unfortunately urllib3 painted itself into a corner by documenting its internals as public APIs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Python-Dev] It's now time to deprecate the stdlib urllib module
I propose to deprecate the urllib module in Python 3.11. It would emit ... In 2011, the "requests" module based on urllib3 was...
Read more >
Utilities - urllib3 1.26.13 documentation
A retry is initiated if the request method is in allowed_methods and the response status code is in status_forcelist . By default, this...
Read more >
urllib.request — Extensible library for opening URLs — Python ...
The urllib.request module defines functions and classes which help in opening URLs (mostly HTTP) in a complex world — basic and digest authentication, ......
Read more >
Victor Stinner on Twitter: ""It's now time to deprecate the stdlib ...
I propose to deprecate the urllib module in Python 3.11. There are better alternatives which ... IMO it's ok to require pulling your...
Read more >
How do I disable log messages from the Requests library?
You only need to ask the urllib3 library to not propagate: logging.getLogger("urllib3").propagate = False , or increase the logging level if you still...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found