Skip to content

Generator expression with 'and' conditional fails to decompile in 2.6 #283

Closed
@trengri

Description

@trengri

The following line of code cannot be decompiled when compiled with Python 2.6.

G = ( c for c in 'SPAM' if c > 'A' and c < 'S')

When compiled with Python 2.7, it is decompiled fine.
If I replace 'and' with 'or' it is also decompiled fine.

Link to the bytecode: https://ufile.io/fiv06gs5
The source code consists of the single line mentioned above.

Command output

$ uncompyle6 genexp.pyc
# uncompyle6 version 3.3.5
# Python bytecode 2.6 (62161)
# Decompiled from: Python 2.7.5 (default, Mar 26 2019, 22:13:06)
# [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)]
# Embedded file name: ./genexp.py
# Compiled at: 2019-08-05 11:14:15



# file genexp.pyc
# --- This code section failed: ---

   1       0  SETUP_LOOP           48  'to 51'
           3  LOAD_FAST             0  '.0'
           6  FOR_ITER             41  'to 50'
           9  STORE_FAST            1  'c'
          12  LOAD_FAST             1  'c'
          15  LOAD_CONST               'A'
          18  COMPARE_OP            4  >
          21  JUMP_IF_FALSE        22  'to 46'
          24  POP_TOP
          25  LOAD_FAST             1  'c'
          28  LOAD_CONST               'S'
          31  COMPARE_OP            0  <
          34  JUMP_IF_FALSE         9  'to 46'
          37  POP_TOP
          38  LOAD_FAST             1  'c'
          41  YIELD_VALUE
          42  POP_TOP
          43  JUMP_BACK             6  'to 6'
        46_0  COME_FROM            34  '34'
        46_1  COME_FROM            21  '21'
          46  POP_TOP
          47  JUMP_BACK             6  'to 6'
          50  POP_BLOCK
        51_0  COME_FROM             0  '0'

Parse error at or near `None' instruction at offset -1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions