Opened 12 years ago
Closed 12 years ago
#19944 closed Bug (fixed)
django 1.5 is not compatible with pypy 1.9 because of django.test._doctest
Reported by: | Mikhail Korobov | Owned by: | Aymeric Augustin |
---|---|---|---|
Component: | Python 2 | Version: | 1.5 |
Severity: | Normal | Keywords: | pypy |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Latest released pypy (1.9) doesn't provide __globals__
attribute and this attribute was introduced in process of making django.test._doctest Python 3.x compatible in this commit: https://github.com/django/django/commit/f1d5dc81ac37fe9a7c7ca860900ee6a16150bb09. It causes tests (of external django apps) to fail when executed under pypy 1.9 with django 1.5 (with an unhelpful AttributeError: 'function' object has no attribute '__globals__'
error without a stack trace).
Example: https://travis-ci.org/kmike/django-webtest/jobs/5097045
I think there should be a fallback to func_globals if __globals__
is not available.
Change History (12)
comment:1 by , 12 years ago
comment:2 by , 12 years ago
__globals__
isn't documented for Python 2.x; I'm surprised the bug occurs under PyPy and not Python 2.x. I don't remember exactly what I checked before making this commit.
comment:3 by , 12 years ago
Has patch: | set |
---|
Pull request: https://github.com/django/django/pull/869
There are similar "dangerous" attributes: "__code__"
, "__closure__"
, "__defaults__"
, "__func__"
and "__self__"
.
"__globals__"
and "__code__"
are fixed in this pull request.
"__closure__"
and "__defaults__"
are not used in django; "__func__"
and "__self__"
are mentioned in Python 2.6 release notes so it should be fine to use them.
comment:4 by , 12 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:5 by , 12 years ago
Now I remember. I was sloppy for this module. I skimmed Vinay Sajip's patch and applied it.
Obviously I should have re-done the porting myself, like I did for every other module in Django.
comment:6 by , 12 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
I filed an issue against six to figure out whether this is an oversight in six or whether there's a better alternative:
https://bitbucket.org/gutworth/six/issue/21/additional-object-model-compatibility
comment:7 by , 12 years ago
Component: | Testing framework → Python 2 |
---|
comment:8 by , 12 years ago
Benjamin added the functions we needed to six. I'm going to update the bundled version of six and then fix this.
comment:9 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
comment:10 by , 12 years ago
Thanks!
Could you apply the fixes to 1.5.x as well (pull request was to 1.5.x)? Not being able to run tests == not being able to use PyPy at all, and an inability to use a certain Python interpreter with django is a pretty serious issue IMHO (I'd even call it a release blocker), and this is 1.5 regression.
comment:11 by , 12 years ago
Resolution: | fixed |
---|---|
Status: | closed → new |
I tried backporting the two commits to 1.5 and I got conflicts, I'll fix that later today.
comment:12 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
It is not necessary for test suite to include doctests to become incompatible with django 1.5 & pypy 1.9.