-
Notifications
You must be signed in to change notification settings - Fork 587
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
filter fails for some lambda functions #379
Comments
Hmm. That's unfortunate. It's probably an upstream bug in uncompyle6, but it might be an oddity in how I'm invoking it. I'm on a break at the moment, so I'm afraid I'm probably not going to be going to looking into this in depth in the near future. In the meantime I'd recommend working around it by defining a named function. Sorry. PS. I've fixed the release tag issue. Thanks for pointing it out. |
Oh, BTW, I think the reliable way to trigger this is going to be to call repr() on the strategy object. The random factor will be because that only happens in a small fraction of test runs because that filter is usually satisfied. |
Ah, OK. That explains the non-determinism. Here is a reduced test case that works every time:
Also, the suggested workaround of named function does not work:
still fails in the same way. |
PS: I understand and sympathize with the reasoning for your break. Please don't feel any obligations. I'm just posting this bug so that it is known. |
Ah, no, the suggested workaround is: def workaround(x):
return not x.endswith('.')
@given(text(min_size=1).filter(workaround))
def go(value1):
pass The bug comes from when Hypothesis tries to get a string representation for the lambda, which it won't do if the function object has a sensible name. And please do feel free to continue to post bugs, and thanks for reporting them! I'll probably still respond to them and will definitely look at them properly when I'm back on duty :-) |
@movermeyer I think you need to make it not-a-lambda like this:
(Excuse the formatting, doing this on a phone) |
Ah, thanks. Much better. |
Beaten to the punch :) |
I started seeing this error consistently, and then suddenly it's disappeared for me as well :/. I'll try to follow up with my own example as soon as I can get it to happen again. |
So I've just observed that the Hypothesis build is also seeing this issue consistently. This pretty strongly suggests that it's the result of a version bump in uncompyle6. If someone wants to debug this and post a bug upstream that would be lovely. :-) If not, pinning to an older version of uncompyle6 is probably also a viable workaround. This might also be a sign that Hypothesis adding a dependency on uncompyle6 was a bad move on my part. It was always a bit of an unsupported use case for the tool. |
I just tried to repro this issue on macOS, running Python 3.5.0 and a variety of uncompyle6 versions, and I’m not seeing any issues. 😕 But there was an uncompyle6 version bump right around the time this started happening (timestamp on @movermeyer’s original post is 25 October, PyPI says 26 October, but timezone interactions are weird). I’ve opened a PR that pins the version to get running against Hypothesis CI. Maybe that will have better luck finding (or not finding?) the problem. |
@movermeyer Could I get the output of |
|
At last, a successful Travis run in #381! So it seems like the issue is somewhere xdis 3.2.0, and we need the following pins:
@movermeyer Could you try installing those versions and let me know if that resolves the issue for you? Assuming my pins are correct, we need to:
Does that sound like a sensible plan @DRMacIver? |
We install uncompyle6 as an explicit dependency in the oldpy27 tox environment. I’m not entirely sure why the test passed without my extra pin, but given what uncompyle6 is up to, I could believe this is the sort of subtle bug that might affect different minor versions of Python. https://github.com/HypothesisWorks/hypothesis-python/blob/master/tox.ini#L34 We should either add another pin to be safe, or remove this dependency in |
I’m now very confident this is an upstream bug that’s fixed by pinning dependencies. (Something I could have figured out much quicker if I’d actually read the exception message!) Hopefully just a small change upstream, and then Hypothesis will be back to rights. Hooray! |
Good news and bad news:
I think there remains a strong argument for restricting the max version of dependencies until they’ve been qualified in Hypothesis CI. Less hassle than an explicit version pin, but makes it easier to spot this sort of bug |
With apologies for a slightly roundabout debugging approach, I believe this is now fixed. We have a clean CI run with uncompyle 2.9.3 and xdis 3.2.1, which does not feature this @movermeyer Please can you run |
@alexwlchan, that seems to work. Thanks for putting in the time to investigate this. |
...but I'm about to invalidate most of @alexwlchan's hard work (sorry again Alex, but thanks for doing it anyway as I wouldn't have noticed this without it). :-( It turns out that the uncompyle6 dependency snuck in some GPL code under the radar. Between that (and my being already predisposed to do so by this issue), I've released Hypothesis 3.6.0 which restores the code that uncompyle6 was used to replace and drops the uncompyle6 dependency. You should probably upgrade to that. |
I stumbled across this bug. For some lambda functions (I've only found this one so far), hypothesis will sometimes fail.
This is the best test case I've been able to develop thus far:
Then
env/bin/python test.py
, with some probability (about 20% on my machine), causes the following exception:I'm running hypothesis (3.5.3) on CentOS 7, with Python 2.7.5 in a virtualenv.
Aside: This happens to occur in proximity to this possibly telling comment.
Another Aside: Github doesn't list 3.5.3 in the releases tab, but it exists on PyPi
The text was updated successfully, but these errors were encountered: