Discussion:
HTMLParser in 2to3
see
2008-12-15 20:18:41 UTC
Permalink
hi,
(hope this is the right forum for this kind of question...)

While testing the 2to3 tool for a lib of mine I noticed imports for
HTMLParser seem not to be changed yet.

I guess the following should happen:

import HTMLParser
# or
from HTMLParser import HTMLParser

should get

import html.parser
# or
from html.parser import HTMLParser

?

thanks
Chris
Brett Cannon
2008-12-15 22:44:09 UTC
Permalink
Post by see
hi,
(hope this is the right forum for this kind of question...)
While testing the 2to3 tool for a lib of mine I noticed imports for
HTMLParser seem not to be changed yet.
Please file a bug report at http://bugs.python.org so this doesn't get lost.
Post by see
import HTMLParser
# or
from HTMLParser import HTMLParser
should get
import html.parser
# or
from html.parser import HTMLParser
The last should be ``from html import pasrser as HTMLParser``.

-Brett
Benjamin Peterson
2008-12-16 02:10:06 UTC
Permalink
Received: from localhost (HELO bag.python.org) (127.0.0.1)
by bag.python.org with SMTP; 16 Dec 2008 03:10:06 +0100
X-policyd-weight: using cached result; rate: -8.4
Received: from mail-ew0-f17.google.com (mail-ew0-f17.google.com
[209.85.219.17]) by bag.python.org (Postfix) with ESMTP;
Tue, 16 Dec 2008 03:10:06 +0100 (CET)
Received: by ewy10 with SMTP id 10so3423410ewy.13
for <multiple recipients>; Mon, 15 Dec 2008 18:10:06 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
h=domainkey-signature:received:received:message-id:date:from:to
:subject:cc:in-reply-to:mime-version:content-type
:content-transfer-encoding:content-disposition:references;
bh=06gSnWw9SrRSh8wG35ontxqhyY/IEadFHuOzXVvt7GM=;
b=Zq6NeeYFAgeV6hGuxA4pjblLm4TmoZIabjPpVj9xo6qvKzfRbLr2qcJR+JuLyJdgaH
8HlUp2LSYISqcA3POGCiHDISG+0kG5e+CqwmJGSKua+mLN/D8sS7VBZJ8ALOzcqxwpU5
0PYeObfFzS4HjB5PBbrjzqDuqWo8b3JK/D0e4=
DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;
h=message-id:date:from:to:subject:cc:in-reply-to:mime-version
:content-type:content-transfer-encoding:content-disposition
:references;
b=rsQGklQ79W8esxpE7Mr5rrfTARVu9MVTG7JMP8nj5Q8zS9rYG8F6tZVRDDgNx8k1VJ
unqVtGEEBleLgnGFx6JsIOffWE4InOQtN0lbPNJKIW10gGAdUGif+cpLgFXdsXHQ4klg
ihSVCCoplhBk6cn1uJcuvr9cLyFXqWgXbaVG8=
Received: by 10.210.66.13 with SMTP id o13mr5323309eba.172.1229393406722;
Mon, 15 Dec 2008 18:10:06 -0800 (PST)
Received: by 10.210.76.1 with HTTP; Mon, 15 Dec 2008 18:10:06 -0800 (PST)
In-Reply-To: <bbaeab100812151444g21437119k3e3ed993f06c6cba-JsoAwUIsXosN+***@public.gmane.org>
Content-Disposition: inline
X-BeenThere: python-porting-+ZN9ApsXKcEdnm+***@public.gmane.org
X-Mailman-Version: 2.1.10
Precedence: list
List-Id: "Discussion about porting Python code \(mainly 2.x -> 3.x\)"
<python-porting.python.org>
List-Unsubscribe: <http://mail.python.org/mailman/options/python-porting>,
<mailto:python-porting-request-+ZN9ApsXKcEdnm+***@public.gmane.org?subject=unsubscribe>
List-Archive: <http://mail.python.org/pipermail/python-porting>
List-Post: <mailto:python-porting-+ZN9ApsXKcEdnm+***@public.gmane.org>
List-Help: <mailto:python-porting-request-+ZN9ApsXKcEdnm+***@public.gmane.org?subject=help>
List-Subscribe: <http://mail.python.org/mailman/listinfo/python-porting>,
<mailto:python-porting-request-+ZN9ApsXKcEdnm+***@public.gmane.org?subject=subscribe>
Sender: python-porting-bounces+gcpp-python-porting=m.gmane.org-+ZN9ApsXKcEdnm+***@public.gmane.org
Errors-To: python-porting-bounces+gcpp-python-porting=m.gmane.org-+ZN9ApsXKcEdnm+***@public.gmane.org
Archived-At: <http://permalink.gmane.org/gmane.comp.python.porting/7>
Post by Brett Cannon
Post by see
hi,
(hope this is the right forum for this kind of question...)
While testing the 2to3 tool for a lib of mine I noticed imports for
HTMLParser seem not to be changed yet.
Please file a bug report at http://bugs.python.org so this doesn't get lost.
Don't bother filing a report; this is fixed in the 2to3 trunk:

$ ./2to3 -
RefactoringTool: Skipping implicit fixer: buffer
RefactoringTool: Skipping implicit fixer: idioms
RefactoringTool: Skipping implicit fixer: set_literal
RefactoringTool: Skipping implicit fixer: ws_comma
import HTMLParser
from HTMLParser import HTMLParser
--- <stdin> (original)
+++ <stdin> (refactored)
@@ -1,2 +1,2 @@
-import HTMLParser
-from HTMLParser import HTMLParser
+import html.parser
+from html.parser import HTMLParser
RefactoringTool: Files that need to be modified:
RefactoringTool: <stdin>
--
Cheers,
Benjamin Peterson
"There's nothing quite as beautiful as an oboe... except a chicken
stuck in a vacuum cleaner."
see
2008-12-16 19:35:11 UTC
Permalink
Post by Benjamin Peterson
Post by Brett Cannon
Post by see
hi,
(hope this is the right forum for this kind of question...)
While testing the 2to3 tool for a lib of mine I noticed imports for
HTMLParser seem not to be changed yet.
Please file a bug report at http://bugs.python.org so this doesn't get lost.
$ ./2to3 -
RefactoringTool: Skipping implicit fixer: buffer
RefactoringTool: Skipping implicit fixer: idioms
RefactoringTool: Skipping implicit fixer: set_literal
RefactoringTool: Skipping implicit fixer: ws_comma
import HTMLParser
from HTMLParser import HTMLParser
--- <stdin> (original)
+++ <stdin> (refactored)
@@ -1,2 +1,2 @@
-import HTMLParser
-from HTMLParser import HTMLParser
+import html.parser
+from html.parser import HTMLParser
RefactoringTool: <stdin>
great, thanks.

BTW, will the 2to3 tool be released in other cycles than Py3k, guess not
every small bugfix will trigger a full release...
So I guess my question would be, is there a separate download somewhere?

Chris
Benjamin Peterson
2008-12-17 03:14:19 UTC
Permalink
Received: from localhost (HELO bag.python.org) (127.0.0.1)
by bag.python.org with SMTP; 17 Dec 2008 04:14:24 +0100
X-policyd-weight: NOT_IN_ZEN_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5
NOT_IN_BL_NJABL=-1.5 CL_IP_EQ_HELO_IP=-2 (check from: .gmail. -
helo: .nf-out-0910.google. - helo-domain: .google.)
FROM/MX_MATCHES_HELO(DOMAIN)=-2 IN_PM_RFCI=0.1
<client=64.233.182.190> <helo=nf-out-0910.google.com>
<from=musiccomposition-***@public.gmane.org>
<to=python-porting-+ZN9ApsXKcEdnm+***@public.gmane.org>, rate: -8.4
Received: from nf-out-0910.google.com (nf-out-0910.google.com [64.233.182.190])
by bag.python.org (Postfix) with ESMTP;
Wed, 17 Dec 2008 04:14:19 +0100 (CET)
Received: by nf-out-0910.google.com with SMTP id 30so495957nfu.31
for <multiple recipients>; Tue, 16 Dec 2008 19:14:19 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
h=domainkey-signature:received:received:message-id:date:from:to
:subject:cc:in-reply-to:mime-version:content-type
:content-transfer-encoding:content-disposition:references;
bh=gNeJYRXZtlJLlVdlb1aYDKV2sf7WiOWGSIwqSDUTK/k=;
b=lHTDAgwO+NTEHuhZhR2I5QoSS+gY82TPD5kuinopmb6eqqxejTZp3yZ96IjXKJhxW4
EpdlmeMhEtXl+DYDELDS+yhPfIJZwOrxD2U6hMNt6AO1SzdF7qjQELmwp6TTQ3VaOUwg
FLCJjXLpJMAbBYyA351lo7fa8vKBCFT+kU0cA=
DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;
h=message-id:date:from:to:subject:cc:in-reply-to:mime-version
:content-type:content-transfer-encoding:content-disposition
:references;
b=lrV/ZOb8W3YKM+N4eOkOPNzHgxwRKwTj0zy5I+H9myaJATgFiWN3bEik7Mzxg0kEg6
NxkhuyTKKafsCKA3IIJ0Lmv9OJLINm/RFReWsvoIDQ8fJdt9vjDDzzCAVDovZ1BKho61
QX0SrbIVKK1e4CCGjYMsLrTWxnkAeMgtQBGuY=
Received: by 10.210.124.8 with SMTP id w8mr241083ebc.92.1229483659058;
Tue, 16 Dec 2008 19:14:19 -0800 (PST)
Received: by 10.210.76.1 with HTTP; Tue, 16 Dec 2008 19:14:19 -0800 (PST)
In-Reply-To: <494802EF.2040201-***@public.gmane.org>
Content-Disposition: inline
X-BeenThere: python-porting-+ZN9ApsXKcEdnm+***@public.gmane.org
X-Mailman-Version: 2.1.10
Precedence: list
List-Id: "Discussion about porting Python code \(mainly 2.x -> 3.x\)"
<python-porting.python.org>
List-Unsubscribe: <http://mail.python.org/mailman/options/python-porting>,
<mailto:python-porting-request-+ZN9ApsXKcEdnm+***@public.gmane.org?subject=unsubscribe>
List-Archive: <http://mail.python.org/pipermail/python-porting>
List-Post: <mailto:python-porting-+ZN9ApsXKcEdnm+***@public.gmane.org>
List-Help: <mailto:python-porting-request-+ZN9ApsXKcEdnm+***@public.gmane.org?subject=help>
List-Subscribe: <http://mail.python.org/mailman/listinfo/python-porting>,
<mailto:python-porting-request-+ZN9ApsXKcEdnm+***@public.gmane.org?subject=subscribe>
Sender: python-porting-bounces+gcpp-python-porting=m.gmane.org-+ZN9ApsXKcEdnm+***@public.gmane.org
Errors-To: python-porting-bounces+gcpp-python-porting=m.gmane.org-+ZN9ApsXKcEdnm+***@public.gmane.org
Archived-At: <http://permalink.gmane.org/gmane.comp.python.porting/11>
Post by see
great, thanks.
BTW, will the 2to3 tool be released in other cycles than Py3k, guess not
every small bugfix will trigger a full release...
So I guess my question would be, is there a separate download somewhere?
You can download the current version from SVN. (It's kept quite stable.)

http://svn.python.org/projects/sandbox/trunk/2to3
Post by see
Chris
--
Cheers,
Benjamin Peterson
"There's nothing quite as beautiful as an oboe... except a chicken
stuck in a vacuum cleaner."
Martin v. Löwis
2008-12-17 06:16:37 UTC
Permalink
Post by see
BTW, will the 2to3 tool be released in other cycles than Py3k, guess not
every small bugfix will trigger a full release...
So I guess my question would be, is there a separate download somewhere?
So far, there has not been a single stand-alone release of 2to3. People
wanting to use a newer version have always checked from subversion.

Regards,
Martin

Christof Hoeke
2008-12-16 20:58:33 UTC
Permalink
Post by Brett Cannon
Post by see
import HTMLParser
# or
from HTMLParser import HTMLParser
should get
import html.parser
# or
from html.parser import HTMLParser
The last should be ``from html import pasrser as HTMLParser``.
-Brett
not to want to split hairs but the second example ``from HTMLParser
import HTMLParser`` actually imports the HTMLParser class and not the
module so I think my original thinking was right?

thanks
Chris
Fred Drake
2008-12-17 02:06:17 UTC
Permalink
Post by Christof Hoeke
not to want to split hairs but the second example ``from HTMLParser
import HTMLParser`` actually imports the HTMLParser class and not
the module so I think my original thinking was right?
Please, split hairs!

Yes, your original proposed re-writes are correct.


-Fred
--
Fred Drake <fdrake at acm.org>
Loading...