Problem executing samples with Python 2.7.3

Issue #12 resolved
Anonymous created an issue

Trying to execute the samples and in the samples folders with a freshly installed Python 2.7.3 (Windows 7 Pro, 64Bit) produces an error (on my machine):

Failed example:
    f = parse("int f(int a, long b) { do_this; do_that; }", Function, comment=comment_c)
Exception raised:
    Traceback (most recent call last):
      File "c:\Python27\lib\", line 1289, in __run  compileflags, 1) in test.globs
      File "<doctest __main__[0]>", line 1, in <module>
        f = parse("int f(int a, long b) { do_this; do_that; }", Function, comment=comment_c)
      File "c:\Python27\lib\site-packages\pypeg2\", line 563, in parse t, r = parser.parse(text, thing)
      File "c:\Python27\lib\site-packages\pypeg2\", line 837, in _parse for i in range(_max):
    OverflowError: Python int too large to convert to C long
1 items had failures:
  12 of  20 in __main__
***Test Failed*** 12 failures.

Perhaps this happens due to my stupidity, perhaps it's worth looking into it closer, I just thought it might be useful to let you know.


Comments (6)

  1. Volker Birk repo owner

    Something else seems to go wrong, because here it works:

    vb@bayhorse:~/pyPEG2 % PYTHON=python2.7 make -e test
    PYTHONPATH=`pwd` python2.7 pyPEG2/test/
    Ran 43 tests in 0.009s
    PYTHONPATH=`pwd` python2.7 pyPEG2/test/
    Ran 5 tests in 0.002s
    PYTHONPATH=`pwd` python2.7 samples/
    PYTHONPATH=`pwd` python2.7 samples/
    vb@bayhorse:~/pyPEG2 % python2.7 --version
    Python 2.7.3
    vb@bayhorse:~/pyPEG2 %

    Could you please explain, with which command are you starting the samples?

  2. Volker Birk repo owner

    This looks like a Python implementation bug in your interpreter. In the code I'm using sys.maxsize – this is defined as the biggest number which fits in an int.

    By definition, this error should never occur.

  3. Anatoly Ananko

    Sems like pyPEG2 bug nevertheless. For python2, not for python3. Sorry, I'm not a python expert and can't say how to fix it best. But python2 documentation states that there are two constants: sys.maxint - The largest positive integer supported by Python’s regular integer type. This is at least 2*31-1. The largest negative integer is -maxint-1 — the asymmetry results from the use of 2’s complement binary arithmetic. sys.maxsize - The largest positive integer supported by the platform’s Py_ssize_t type, and thus the maximum size lists, strings, dicts, and many other containers can have.

    Python 2.7.6 | 64-bit | (default, Jun  4 2014, 16:30:34) [MSC v.1500 64 bit (AMD64)] on win32
    In[3]: sys
    Out[3]: <module 'sys' (built-in)>
    In[4]: sys.maxint
    Out[4]: 2147483647
    In[5]: sys.maxsize
    Out[5]: 9223372036854775807L

    A bit strange behaviour, but it seems to be correct according to documentation. In python3 this behaviour is avioded by leaving just one of the constants - sys.maxsize

  4. Log in to comment