[Ironpython-users] PyPDF error

Curt Hagenlocher curt at hagenlocher.org
Thu Dec 29 17:15:20 CET 2011


This looks like a bug in IronPython when deriving a class from int. Here's
a simple repro; file a bug!

In IronPython 2.7.1,

>>> class Integer(int):
...     def __init__(self, value):
...         int.__init__(value)
...
>>> Integer(10)
10
>>> Integer('10')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: expected int, got str
>>> int('10')
10
>>>

In Python 2.6,
>>> class Integer(int):
...     def __init__(self, value):
...         int.__init__(value)
...
>>> Integer(10)
10
>>> Integer('10')
10
>>> int('10')
10
>>>
On Thu, Dec 29, 2011 at 7:30 AM, Chris <phatfish at gmail.com> wrote:

> Hi,
>
> Can anyone explain this bellow. Does PyPDF use some unsported part of the
> standard lib? Because there are no external modules required for it.
> On another note, is there a way for the "Execute Project in Python
> Interactive" to use the vanilla Python interpreter rather than the
> IronPython one. I cant see a way to change this?
>
> Thanks
>
> *Python 2.7 Interactive Window*
>
>  Resetting execution engine
> >>> from pyPdf import PdfFileReader
> >>> pdf = PdfFileReader(open('D:/Chris/Documents/sorting/short
> numbers/2370.pdf', 'rb'))
> >>> print 'test'
> test
> >>>
>
> *IronPython 2.7 Interactive Window*
>
> >>> from pyPdf import PdfFileReader
> >>> pdf = PdfFileReader(open('D:/Chris/Documents/sorting/short
> numbers/2370.pdf', 'rb'))
> Traceback (most recent call last):
>   File "<string>", line 1, in <module>
>   File "C:\Program Files (x86)\IronPython
> 2.7.1\lib\site-packages\pyPdf\pdf.py", line 374, in __init__
>     self.read(stream)
>   File "C:\Program Files (x86)\IronPython
> 2.7.1\lib\site-packages\pyPdf\pdf.py", line 732, in read
>     num = readObject(stream, self)
>   File "C:\Program Files (x86)\IronPython
> 2.7.1\lib\site-packages\pyPdf\generic.py", line 87, in readObject
>     return NumberObject.readFromStream(stream)
>   File "C:\Program Files (x86)\IronPython
> 2.7.1\lib\site-packages\pyPdf\generic.py", line 236, in readFromStream
>     return NumberObject(name)
> TypeError: expected int, got str
> >>>
>
> _______________________________________________
> Ironpython-users mailing list
> Ironpython-users at python.org
> http://mail.python.org/mailman/listinfo/ironpython-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20111229/9d2b9785/attachment.html>


More information about the Ironpython-users mailing list