[New-bugs-announce] [issue8877] 2to3 fixes stdlib import wrongly

Dirkjan Ochtman report at bugs.python.org
Wed Jun 2 16:09:05 CEST 2010


New submission from Dirkjan Ochtman <dirkjan at ochtman.nl>:

djc at 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 at enrai src $ cat test/http.py
from httplib import BadStatusLine
djc at 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.

----------
components: 2to3 (2.x to 3.0 conversion tool)
messages: 106882
nosy: djc
priority: normal
severity: normal
status: open
title: 2to3 fixes stdlib import wrongly
versions: Python 3.1

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue8877>
_______________________________________


More information about the New-bugs-announce mailing list