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

Deprecate strict mode of HTMLParser #59319

Closed
ezio-melotti opened this issue Jun 20, 2012 · 12 comments
Closed

Deprecate strict mode of HTMLParser #59319

ezio-melotti opened this issue Jun 20, 2012 · 12 comments
Assignees
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@ezio-melotti
Copy link
Member

BPO 15114
Nosy @birkenfeld, @ezio-melotti, @merwok, @bitdancer, @berkerpeksag
Files
  • issue15114.diff
  • issue15114-2.diff: Patch for 3.4.
  • issue15114-3.diff: Patch for 3.5.
  • 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 = 'https://github.com/ezio-melotti'
    closed_at = <Date 2014-08-02.11:13:18.985>
    created_at = <Date 2012-06-20.09:42:50.624>
    labels = ['type-bug', 'library']
    title = 'Deprecate strict mode of HTMLParser'
    updated_at = <Date 2014-08-02.15:54:53.660>
    user = 'https://github.com/ezio-melotti'

    bugs.python.org fields:

    activity = <Date 2014-08-02.15:54:53.660>
    actor = 'python-dev'
    assignee = 'ezio.melotti'
    closed = True
    closed_date = <Date 2014-08-02.11:13:18.985>
    closer = 'ezio.melotti'
    components = ['Library (Lib)']
    creation = <Date 2012-06-20.09:42:50.624>
    creator = 'ezio.melotti'
    dependencies = []
    files = ['26067', '27528', '32535']
    hgrepos = []
    issue_num = 15114
    keywords = ['patch']
    message_count = 12.0
    messages = ['163265', '163273', '163337', '163570', '163604', '163605', '163608', '201976', '202363', '224551', '224552', '224575']
    nosy_count = 7.0
    nosy_names = ['georg.brandl', 'ezio.melotti', 'eric.araujo', 'Arfrever', 'r.david.murray', 'python-dev', 'berker.peksag']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue15114'
    versions = ['Python 3.5']

    @ezio-melotti
    Copy link
    Member Author

    The deprecation plan for the strict mode of HTMLParser might be as follow:

    3.3 (before the beta)
    strict=False default
    strict arg deprecated in the doc
    strict=True deprecated (raises a warning)
    HTMLParseError deprecated
    HTMLParser.error deprecated (raises a warning)
    calls to HTMLParser.error removed/converted to asserts

    3.4
    strict arg deprecated (raises a warning)

    3.5
    strict arg removed and strict code removed
    HTMLParseError removed
    HTMLParser.error removed

    Everything that is parsed by strict=True is parsed by strict=False too, so changing the default shouldn't be a problem. The difference is that strict=False won't raise any error and will parse broken markup too. Given that no errors are raised HTMLParseError and HTMLParser.error become useless and can be deprecated (3.3) and removed (3.5) too.
    Once strict=False is the default (3.3), the instances should be created simply with HTMLParser(), and eventually the strict argument will be deprecated (3.4) and removed (3.5).

    @ezio-melotti ezio-melotti self-assigned this Jun 20, 2012
    @ezio-melotti ezio-melotti added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Jun 20, 2012
    @bitdancer
    Copy link
    Member

    Your plan sounds fine to me.

    @ezio-melotti
    Copy link
    Member Author

    The attached patch include these changes:

    • strict=False default
    • strict arg deprecated in the doc
    • strict=True deprecated (raises a warning)
    • HTMLParseError deprecated in the doc
    • some calls to HTMLParser.error converted to asserts [0]

    Regarding

    • HTMLParser.error deprecated (raises a warning)
      I'm not sure anymore that's a good idea. The method is not documented, so in theory it could be removed without deprecation warnings, but that might break things if someone is using it.

    [0] I made a mistake in my first message: some of the calls should actually be converted to assert, the others will stay as long as the strict mode exists (i.e. they will be removed in 3.5)

    @birkenfeld
    Copy link
    Member

    Why not deprecate .error()? Removing it immediately as undocumented is certainly not better.

    Otherwise sounds good, please commit.

    @ezio-melotti
    Copy link
    Member Author

    Regarding .error() I think the best thing to do is wait till 3.4 and then deprecate it.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Jun 23, 2012

    New changeset 8dd2f5754b2f by Ezio Melotti in branch 'default':
    bpo-15114: the strict mode of HTMLParser and the HTMLParseError exception are deprecated now that the parser is able to parse invalid markup.
    http://hg.python.org/cpython/rev/8dd2f5754b2f

    @ezio-melotti
    Copy link
    Member Author

    3.3 is done.

    3.4
    strict arg deprecated (raises a warning)
    HTMLParser.error deprecated (raises a warning)

    3.5
    strict arg removed and strict code removed
    HTMLParseError removed
    HTMLParser.error and calls to HTMLParser.error removed

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Nov 2, 2013

    New changeset 0a56709eb798 by Ezio Melotti in branch 'default':
    bpo-15114: The html.parser module now raises a DeprecationWarning when the strict argument of HTMLParser or the HTMLParser.error method are used.
    http://hg.python.org/cpython/rev/0a56709eb798

    @ezio-melotti
    Copy link
    Member Author

    3.4 is done.

    3.5
    strict arg removed and strict code removed
    HTMLParseError removed
    HTMLParser.error and calls to HTMLParser.error removed

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Aug 2, 2014

    New changeset 0e2e47c1f205 by Ezio Melotti in branch 'default':
    bpo-15114: the strict mode and argument of HTMLParser, HTMLParser.error, and the HTMLParserError exception have been removed.
    http://hg.python.org/cpython/rev/0e2e47c1f205

    @ezio-melotti
    Copy link
    Member Author

    3.5 is done.
    Closing.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Aug 2, 2014

    New changeset 5b95f3fdcc0b by Ezio Melotti in branch 'default':
    bpo-15114, bpo-21047: update whatsnew in Python 3.5.
    http://hg.python.org/cpython/rev/5b95f3fdcc0b

    @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
    Labels
    stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants