[New-bugs-announce] [issue9259] Python 2.7 breaks assigned __exit__s

Ariel Ben-Yehuda report at bugs.python.org
Wed Jul 14 13:53:18 CEST 2010

New submission from Ariel Ben-Yehuda <ariel.bys at gmail.com>:

Hello, I think there is a problem with Python 2.7: I installed it, and tried to compile GObject-Introspection 0.9.2. Here is the result:

  GISCAN GLib-2.0.gir
Traceback (most recent call last):
  File "../tools/g-ir-scanner", line 36, in <module>
    from giscanner.scannermain import scanner_main
  File "/sources/gobject-introspection-0.9.2/giscanner/scannermain.py", line 31, in <module>
    from giscanner.dumper import compile_introspection_binary
  File "/sources/gobject-introspection-0.9.2/giscanner/dumper.py", line 26, in <module>
    from .glibtransformer import IntrospectionBinary
  File "/sources/gobject-introspection-0.9.2/giscanner/glibtransformer.py", line 34, in <module>
    from .transformer import Names
  File "/sources/gobject-introspection-0.9.2/giscanner/transformer.py", line 31, in <module>
    from .girparser import GIRParser
  File "/sources/gobject-introspection-0.9.2/giscanner/girparser.py", line 32, in <module>
    from .girwriter import COMPATIBLE_GIR_VERSION
  File "/sources/gobject-introspection-0.9.2/giscanner/girwriter.py", line 30, in <module>
    from .xmlwriter import XMLWriter
  File "/sources/gobject-introspection-0.9.2/giscanner/xmlwriter.py", line 70, in <module>
    with LibtoolImporter:
AttributeError: __exit__

Oops, no GObject-Introspection for me. Investigating the bug, I looked in the recent changes in Python2.7 for something interesting, and found this: 
A new opcode was added to perform the initial setup for with statements, looking up the __enter__()  and __exit__()  methods. (Contributed by Benjamin Peterson.)

Finally, I made 3 test cases to the bug. All 3 produce no input in Python 2.6, but crash pretty nicely in 2.7, the first 2 not finding __exit__ and the last missing __enter__.

I will try to make a patch, however my CPython skills are not so great, so you will probably make a better one.

components: Interpreter Core
files: tests.tar.xz
messages: 110268
nosy: arielbyd
priority: normal
severity: normal
status: open
title: Python 2.7 breaks assigned __exit__s
versions: Python 2.7
Added file: http://bugs.python.org/file17996/tests.tar.xz

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list