Skip to content
This repository has been archived by the owner on May 31, 2020. It is now read-only.

"in" / "not in" do not work as expected. #724

Open
sparkslabs opened this issue Mar 8, 2018 · 2 comments
Open

"in" / "not in" do not work as expected. #724

sparkslabs opened this issue Mar 8, 2018 · 2 comments

Comments

@sparkslabs
Copy link

First of all thanks for writing this. I saw the recording of your talk on this on youtube from a pycon or similar and thought it worth trying. Works really well over all. Many thanks!

With that, the bug report...

Expected Behaviour

The following works in CPython:

resource_id = "foo"
user_resources_done = []

if resource_id not in user_resources_done:
    print("Gotta do that")
else:
    print("Done it")

Specifically it generates the following output:

>>> resource_id = "foo"
>>> user_resources_done = []
>>> if resource_id not in user_resources_done:
...     print("Gotta do that")
... else:
...     print("Done it")
... 
Gotta do that
>>> 

Current Behavior

In Batavia, if I use the same code, I get this:

Traceback (most recent call last):
  File "/tmp/tmpsrv0plrf", line 3, in <module>
ValueError: list.index(x): x not in list

Clearly this is a difference in behaviour.

Steps to reproduce

Using the testserver, copy and paste the above code into the "Run your code!" box, and hit "Run your code!"

Your Environment

  • Batavia version - 3.4.0-dev.19
  • Batavia git hash -- 458cb41 (Dated Sun Mar 4 15:26:23 2018 +0800)
  • Ubuntu Linux 16.04.04 -- LTS
  • Python -- 3.5.2
  • node -- v6.13.1
  • npm -- 5.7.1

Workaround

Obviously this can be worked around in Batavia, but I thought it enough of an issue to raise since the obvious workarounds would only work in Batavia with this bug, not in CPython nor Batavia without this bug.

@freakboy3742
Copy link
Member

Thanks for the comprehensive bug report! Looks like the definition of __contains__ on lists is a bit naïve.

@noahhaasis
Copy link

Is this still open? @vn-ki seems to have solved this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants