You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=<Date2011-11-04.21:17:12.268>created_at=<Date2011-10-28.15:01:14.920>labels= ['type-bug', 'library']
title='urllib.request exposes too many names'updated_at=<Date2011-11-04.21:17:12.267>user='https://github.com/florentx'
This is technically backward incompatible, so if we define an __all__ with most of these names, we are officially making them public, if we leave them out, from urllib.request import * will break for someone.
You could argue that import * is discouraged though.
Let's deprecate some of these (or add deprecation warnings) for
upcoming release. But, doing from xxx import * is not a recommended
way for any module, as we know that it stands to pollute the namespace
with unneccesary functions/methods. I would be careful in adding
anything to __all__ and if done, may go for only 3.3. Ezio has a valid
point.
florentx commented on Oct 28, 2011
florentxmannequin
MannequinAuthor
More actions
We should only expose the names which are documented.
The modules and the objects from urllib.parse don't need to be exposed in urllib.request.
Just the News item is added. I don't think, this requires any Docs update. One change I had to make in the patch is to remote HTTPSHandler from __all__ because that is only conditionally available when http.client supports HTTPSConnection. Neither might this require a docs update because Handlers may be used only within urllib.request namespace and not standalone.
Traceback (most recent call last):
File "D:\cygwin\home\db3l\buildarea\3.x.bolen-windows\build\lib\test\test_urllib2.py", line 32, in test___all__
(k, module, v.__module__))
AssertionError: 'nturl2path' != 'urllib.request'
- nturl2path+ urllib.request
: 'pathname2url' is exposed in 'urllib.request' but defined in 'nturl2path'
Activity
florentx commentedon Oct 28, 2011
In this list we find 14 modules:
['base64', 'collections', 'ssl', 'bisect', 'http', 're', 'email', 'socket', 'os', 'posixpath', 'hashlib', 'io', 'time', 'sys']
And many non-documented functions:
It may be good to define __all__ for this module, and to preprend "_" on some of these names.
ezio-melotti commentedon Oct 28, 2011
This is technically backward incompatible, so if we define an __all__ with most of these names, we are officially making them public, if we leave them out, from urllib.request import * will break for someone.
You could argue that import * is discouraged though.
orsenthil commentedon Oct 28, 2011
Let's deprecate some of these (or add deprecation warnings) for
upcoming release. But, doing from xxx import * is not a recommended
way for any module, as we know that it stands to pollute the namespace
with unneccesary functions/methods. I would be careful in adding
anything to __all__ and if done, may go for only 3.3. Ezio has a valid
point.
florentx commentedon Oct 28, 2011
We should only expose the names which are documented.
The modules and the objects from urllib.parse don't need to be exposed in urllib.request.
I suggest to apply this patch on 3.3 only.
python-dev commentedon Nov 1, 2011
New changeset 70dedd8ce8f3 by Senthil Kumaran in branch 'default':
bpo-13287 - Define __all__ for urllib.request and urllib.error and expose only
http://hg.python.org/cpython/rev/70dedd8ce8f3
orsenthil commentedon Nov 1, 2011
Thanks flox for the patch.
Just the News item is added. I don't think, this requires any Docs update. One change I had to make in the patch is to remote HTTPSHandler from __all__ because that is only conditionally available when http.client supports HTTPSConnection. Neither might this require a docs update because Handlers may be used only within urllib.request namespace and not standalone.
vstinner commentedon Nov 4, 2011
test_urllib2.test___all__() is failing on Windows. Example:
http://www.python.org/dev/buildbot/all/builders/x86%20XP-4%203.x/builds/5498/steps/test/logs/stdio
======================================================================
FAIL: test___all__ (test.test_urllib2.TrivialTests)
----------------------------------------------------------------------
Traceback (most recent call last): File "D:\cygwin\home\db3l\buildarea\3.x.bolen-windows\build\lib\test\test_urllib2.py", line 32, in test___all__ (k, module, v.__module__)) AssertionError: 'nturl2path' != 'urllib.request' - nturl2path + urllib.request : 'pathname2url' is exposed in 'urllib.request' but defined in 'nturl2path'python-dev commentedon Nov 4, 2011
New changeset ca78ed7393bf by Florent Xicluna in branch 'default':
Fix test_urllib2 error on Windows in relation with issue bpo-13287.
http://hg.python.org/cpython/rev/ca78ed7393bf