cpyext: cython-0.28.1 output fails on pypy

Issue #2797 resolved
pv created an issue

The following Cython program fails with Cython-0.28.1 + pypy 3.5 @ 2018-04-11 (e6d85e030f12):

def doit(bytes options):
    x = set()
    x.update(options.split())
    if b"Qz" in x:
        x.remove(b"Qz")

doit(b"Qbb Qc Qz Q12")

as

$ cython3 bad.pyx
$ gcc -I/usr/local/lib/pypy+20180411/include -shared -fPIC -o bad.pypy3-61-x86_64-linux-gnu.so bad.c
$ pypy3 -c 'import bad'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "bad.pyx", line 8, in init bad
    doit(b"Qbb Qc Qz Q12")
  File "bad.pyx", line 6, in bad.doit
    x.remove(b"Qz")
KeyError: b'Qz'

Not sure yet if it's cpyext or Cython issue.

Fails also on pypy3-5.10.1 and pypy2-5.10.0.

Comments (2)

  1. Armin Rigo

    Ah, it's a cpyext issue. PySet_Discard() always return 0, instead of 1 if the item was found and removed.

  2. Log in to comment