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

2to3 fixes stdlib import wrongly #53123

Closed
djc opened this issue Jun 2, 2010 · 3 comments
Closed

2to3 fixes stdlib import wrongly #53123

djc opened this issue Jun 2, 2010 · 3 comments

Comments

@djc
Copy link
Member

djc commented Jun 2, 2010

BPO 8877
Nosy @loewis, @benjaminp, @djc

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 = None
closed_at = <Date 2010-06-02.18:03:50.436>
created_at = <Date 2010-06-02.14:09:03.307>
labels = ['expert-2to3']
title = '2to3 fixes stdlib import wrongly'
updated_at = <Date 2010-06-02.18:03:50.373>
user = 'https://github.com/djc'

bugs.python.org fields:

activity = <Date 2010-06-02.18:03:50.373>
actor = 'benjamin.peterson'
assignee = 'none'
closed = True
closed_date = <Date 2010-06-02.18:03:50.436>
closer = 'benjamin.peterson'
components = ['2to3 (2.x to 3.x conversion tool)']
creation = <Date 2010-06-02.14:09:03.307>
creator = 'djc'
dependencies = []
files = []
hgrepos = []
issue_num = 8877
keywords = []
message_count = 3.0
messages = ['106882', '106897', '106900']
nosy_count = 3.0
nosy_names = ['loewis', 'benjamin.peterson', 'djc']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue8877'
versions = ['Python 3.1']

@djc
Copy link
Member Author

djc commented Jun 2, 2010

djc@enrai src $ ls -l test/*
-rw-r--r-- 1 djc users 34 Jun  2 16:00 test/http.py
-rw-r--r-- 1 djc users  0 Jun  2 16:00 test/__init__.py
djc@enrai src $ cat test/http.py
from httplib import BadStatusLine
djc@enrai src $ 2to3 test/*
RefactoringTool: Skipping implicit fixer: buffer
RefactoringTool: Skipping implicit fixer: idioms
RefactoringTool: Skipping implicit fixer: set_literal
RefactoringTool: Skipping implicit fixer: ws_comma
--- test/http.py (original)
+++ test/http.py (refactored)
@@ -1,1 +1,1 @@
-from httplib import BadStatusLine
+from .http.client import BadStatusLine
RefactoringTool: Files that need to be modified:
RefactoringTool: test/http.py

... which doesn't work, of course. On the other hand, http.py is not in a package, it works correctly. If test/http.py is moved to test/blah.py instead, it also works correctly. 2to3 should be able to conclude that the "httplib" it was before did not refer to .http, but refered to http.client.

@djc djc added the topic-2to3 label Jun 2, 2010
@loewis
Copy link
Mannequin

loewis mannequin commented Jun 2, 2010

Just in case it isn't clear: this is because of the order of fixes. The first fixer replaces httplib with http.client, then the next fixer thinks this is a relative import.

@benjaminp
Copy link
Contributor

And this has been fixed in the lastest versions of 2to3.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants