MemoryError with parser.suite and wrong encoding declaration

Discussion in 'Python' started by Sylvain Thenault, Jan 18, 2005.

  1. Hi there !
    I've noticed the following problem with python >= 2.3 (actually 2.3.4 and
    2.4):

    syt@musca:test$ python
    Python 2.3.4 (#2, Sep 24 2004, 08:39:09)
    [GCC 3.3.4 (Debian 1:3.3.4-12)] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import parser
    >>> parser.suite('# -*- coding: IBO-8859-1 -*-')

    Traceback (most recent call last):
    File "<stdin>", line 1, in ?
    MemoryError
    >>> parser.suite('# -*- coding: ISO-8859-1 -*-')

    <parser.st object at 0xb7e5e060>

    Shouldn't parser.suite just ignore the wrong encoding declaration, or at
    least raise a more appropriate exception. IMHO the first solution
    would be better, since that's the behaviour of the (C) python interpreter.

    --
    Sylvain Thénault LOGILAB, Paris (France).

    http://www.logilab.com http://www.logilab.fr http://www.logilab.org
    Sylvain Thenault, Jan 18, 2005
    #1
    1. Advertising

  2. Sylvain Thenault <> writes:

    > Hi there !
    > I've noticed the following problem with python >= 2.3 (actually 2.3.4 and
    > 2.4):
    >
    > syt@musca:test$ python
    > Python 2.3.4 (#2, Sep 24 2004, 08:39:09)
    > [GCC 3.3.4 (Debian 1:3.3.4-12)] on linux2
    > Type "help", "copyright", "credits" or "license" for more information.
    >>>> import parser
    >>>> parser.suite('# -*- coding: IBO-8859-1 -*-')

    > Traceback (most recent call last):
    > File "<stdin>", line 1, in ?
    > MemoryError
    >>>> parser.suite('# -*- coding: ISO-8859-1 -*-')

    > <parser.st object at 0xb7e5e060>
    >
    > Shouldn't parser.suite just ignore the wrong encoding declaration, or at
    > least raise a more appropriate exception. IMHO the first solution
    > would be better, since that's the behaviour of the (C) python interpreter.


    Ignore the wrong declaration? All Python's that I have (on windows,
    at least) raise a SyntaxError:

    File "x.py", line 1
    SyntaxError: 'unknown encoding: IBO-8859-1'

    See also:

    http://www.python.org/sf/979739

    Thomas
    Thomas Heller, Jan 18, 2005
    #2
    1. Advertising

  3. On Tue, 18 Jan 2005 16:16:32 +0100, Thomas Heller wrote:

    > Sylvain Thenault <> writes:
    >
    >> Hi there !
    >> I've noticed the following problem with python >= 2.3 (actually 2.3.4
    >> and 2.4):
    >>
    >> syt@musca:test$ python
    >> Python 2.3.4 (#2, Sep 24 2004, 08:39:09) [GCC 3.3.4 (Debian 1:3.3.4-12)]
    >> on linux2 Type "help", "copyright", "credits" or "license" for more
    >> information.
    >>>>> import parser
    >>>>> parser.suite('# -*- coding: IBO-8859-1 -*-')

    >> Traceback (most recent call last):
    >> File "<stdin>", line 1, in ?
    >> MemoryError
    >>>>> parser.suite('# -*- coding: ISO-8859-1 -*-')

    >> <parser.st object at 0xb7e5e060>
    >>
    >> Shouldn't parser.suite just ignore the wrong encoding declaration, or at
    >> least raise a more appropriate exception. IMHO the first solution would
    >> be better, since that's the behaviour of the (C) python interpreter.

    >
    > Ignore the wrong declaration? All Python's that I have (on windows, at
    > least) raise a SyntaxError:
    >
    > File "x.py", line 1
    > SyntaxError: 'unknown encoding: IBO-8859-1'


    hum, right (with python >= 2.3 which is the first release using those
    declaration...). I was sure to have checked this but I've obviously
    missed something. Maybe the fact that being able to parse it anyway is
    the solution I wish has driven me to write this ;) I would like this
    behaviour so that pylint can check a module with a wrong encoding
    declaration anyway. But at least, SyntaxError would be better than
    MemoryError.

    > See also:
    >
    > http://www.python.org/sf/979739


    thanks
    --
    Sylvain Thénault LOGILAB, Paris (France).

    http://www.logilab.com http://www.logilab.fr http://www.logilab.org
    Sylvain Thenault, Jan 18, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. vadi

    test suite for C++ parser

    vadi, Oct 3, 2003, in forum: C++
    Replies:
    2
    Views:
    402
    David B. Held
    Oct 3, 2003
  2. Andy Rechenberg
    Replies:
    0
    Views:
    466
    Andy Rechenberg
    Aug 27, 2003
  3. Jamie
    Replies:
    0
    Views:
    369
    Jamie
    Nov 27, 2003
  4. Giulio  Piancastelli

    (Yet Another?) RSS::Parser test suite

    Giulio Piancastelli, Nov 17, 2004, in forum: Ruby
    Replies:
    6
    Views:
    186
    Kouhei Sutou
    Nov 23, 2004
  5. arne
    Replies:
    0
    Views:
    344
Loading...

Share This Page