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 Mikhail Korobov, 12 years ago

It is not necessary for test suite to include doctests to become incompatible with django 1.5 & pypy 1.9.

comment:2 by Aymeric Augustin, 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 Mikhail Korobov, 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 Jacob, 12 years ago

Triage Stage: UnreviewedAccepted

comment:5 by Aymeric Augustin, 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 Aymeric Augustin, 12 years ago

Owner: changed from nobody to Aymeric Augustin
Status: newassigned

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 Aymeric Augustin, 12 years ago

Component: Testing frameworkPython 2

comment:8 by Aymeric Augustin, 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 Aymeric Augustin <aymeric.augustin@…>, 12 years ago

Resolution: fixed
Status: assignedclosed

In 9d4a5b00f1977d8cddf8e241fa4bb8a9e819f188:

Stopped using non-standard globals and code attributes.

Some alternative implementations don't have them.

Closes #19944.

comment:10 by Mikhail Korobov, 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 Aymeric Augustin, 12 years ago

Resolution: fixed
Status: closednew

I tried backporting the two commits to 1.5 and I got conflicts, I'll fix that later today.

comment:12 by Aymeric Augustin <aymeric.augustin@…>, 12 years ago

Resolution: fixed
Status: newclosed

In 1c9bd69ff045cf304fcfe127eac53e8712d33d75:

[1.5.x] Stopped using non-standard globals and code attributes.

Some alternative implementations don't have them.

Closes #19944.

Backport of 9d4a5b00f1977d8cddf8e241fa4bb8a9e819f188 from master.

Note: See TracTickets for help on using tickets.
Back to Top