AttributeError: 'built in-code' object has no attribute 'co_code'

Hi, I'm trying to port django-hotsauce to PyPy. I'm getting an exception when I use Cython compiled under CPython: DEBUG:Traceback (most recent call last): File "lib/notmm/controllers/wsgi.pyx", line 206, in notmm.controllers.wsgi.BaseController.get_response (lib/notmm/controllers/wsgi.c:4174) File "/home/erob/src/django-hotsauce-pypy/lib/notmm/utils/django_compat.py", line 230, in resolve sub_match = pattern.resolve(new_path) File "/home/erob/src/django-hotsauce-pypy/lib/notmm/utils/django_compat.py", line 155, in resolve return (self.callback, args, kwargs) File "/home/erob/src/django-hotsauce-pypy/lib/notmm/utils/django_compat.py", line 166, in _get_callback raise ViewDoesNotExist, "Tried %s in module %s. Error was: %s" % (func_name, mod_name, str(e)) ViewDoesNotExist: Tried index in module mainapp.research.views. Error was: 'builtin-code' object has no attribute 'co_code' Traceback (most recent call last): File "/usr/lib/pypy/lib-python/2.7/wsgiref/handlers.py", line 85, in run self.result = application(self.environ, self.start_response) File "/usr/lib/pypy/lib-python/2.7/wsgiref/validate.py", line 176, in lint_app iterator = application(environ, start_response_wrapper) File "/home/erob/src/django-hotsauce-oauthclient/lib/wsgi_oauth2/middleware.py", line 292, in __call__ return self.application(environ, start_response) File "lib/notmm/controllers/wsgi.pyx", line 136, in notmm.controllers.wsgi.BaseController.__call__ (lib/notmm/controllers/wsgi.c:2842) File "lib/notmm/controllers/wsgi.pyx", line 151, in notmm.controllers.wsgi.BaseController.application (lib/notmm/controllers/wsgi.c:3177) AttributeError: 'builtin-code' object has no attribute 'co_code' 127.0.0.1 - - [12/Oct/2017 16:37:03] "GET / HTTP/1.1" 500 59 In wsgi.pyx: with sessionmanager(environ): request.environ.update(environ) #assert request.environ['PATH_INFO'] == request.path_url response = self.get_response(request=request) return response(environ, start_response) Any ideas why using a @contextmanager here yield this exception with PyPy 5.6.0 and Cython 0.25.2 ? Thank you in advance, Etienne

Hi, On Thu, 12 Oct 2017, Etienne Robillard wrote:
Any ideas why using a @contextmanager here yield this exception with PyPy 5.6.0 and Cython 0.25.2 ?
You are using very outdated versions of both PyPy (latest = 5.9.0) and Cython (latest = 0.27.1), could you please try again with the latest versions? There have been a lot of compatibility work going on both sides, and it is not unlikely that the issue has been fixed in the meantime. -- Sincerely yours, Yury V. Zaytsev

Hi Yury, I upgraded pypy to 5.9.0 and cython to 0.27.1. Compilation of libschevo fails under PyPy: erob@marina:~/src/django-hotsauce-pypy/extras/libschevo$ sudo pypy setup.py develop --prefix=/usr/local/pypy running develop running egg_info writing lib/libschevo.egg-info/PKG-INFO writing dependency_links to lib/libschevo.egg-info/dependency_links.txt writing entry points to lib/libschevo.egg-info/entry_points.txt writing requirements to lib/libschevo.egg-info/requires.txt writing top-level names to lib/libschevo.egg-info/top_level.txt reading manifest file 'lib/libschevo.egg-info/SOURCES.txt' reading manifest template 'MANIFEST.in' warning: no files found matching 'README' anywhere in distribution warning: no files found matching '*' under directory 'schevo/templates' writing manifest file 'lib/libschevo.egg-info/SOURCES.txt' running build_ext building 'schevo.store._s_persistent' extension cc -pthread -DNDEBUG -O2 -fPIC -I/usr/local/pypy/pypy2-v5.9.0-linux32/include -c lib/schevo/store/_s_persistent.c -o build/temp.linux-i686-2.7/lib/schevo/store/_s_persistent.o lib/schevo/store/_s_persistent.c:8:27: fatal error: weakrefobject.h: No such file or directory #include "weakrefobject.h" ^ compilation terminated. error: command 'cc' failed with exit status 1 Will need to investigate further why weakrefobject.h is missing from PyPy or find a workaround. Best Regards, Etienne On 13/10/17 01:16 AM, Yury V. Zaytsev wrote:
You are using very outdated versions of both PyPy (latest = 5.9.0) and Cython (latest = 0.27.1), could you please try again with the latest versions? There have been a lot of compatibility work going on both sides, and it is not unlikely that the issue has been fixed in the meantime.

Hi, Can someone please explain what this TypeError message means? Best Regards, Etienne Traceback (most recent call last): File "/usr/local/pypy/pypy2-v5.9.0-linux32/lib-python/2.7/wsgiref/handlers.py", line 85, in run self.result = application(self.environ, self.start_response) File "/usr/local/pypy/pypy2-v5.9.0-linux32/lib-python/2.7/wsgiref/validate.py", line 176, in lint_app iterator = application(environ, start_response_wrapper) File "/home/erob/src/django-hotsauce-oauthclient/lib/wsgi_oauth2/middleware.py", line 292, in __call__ return self.application(environ, start_response) File "lib/notmm/controllers/wsgi.pyx", line 136, in notmm.controllers.wsgi.BaseController.__call__ TypeError: __weakref__ slot disallowed: we already got one Le 2017-10-13 à 07:22, Etienne Robillard a écrit :
Hi Yury,
I upgraded pypy to 5.9.0 and cython to 0.27.1.
Compilation of libschevo fails under PyPy:
erob@marina:~/src/django-hotsauce-pypy/extras/libschevo$ sudo pypy setup.py develop --prefix=/usr/local/pypy running develop running egg_info writing lib/libschevo.egg-info/PKG-INFO writing dependency_links to lib/libschevo.egg-info/dependency_links.txt writing entry points to lib/libschevo.egg-info/entry_points.txt writing requirements to lib/libschevo.egg-info/requires.txt writing top-level names to lib/libschevo.egg-info/top_level.txt reading manifest file 'lib/libschevo.egg-info/SOURCES.txt' reading manifest template 'MANIFEST.in' warning: no files found matching 'README' anywhere in distribution warning: no files found matching '*' under directory 'schevo/templates' writing manifest file 'lib/libschevo.egg-info/SOURCES.txt' running build_ext building 'schevo.store._s_persistent' extension cc -pthread -DNDEBUG -O2 -fPIC -I/usr/local/pypy/pypy2-v5.9.0-linux32/include -c lib/schevo/store/_s_persistent.c -o build/temp.linux-i686-2.7/lib/schevo/store/_s_persistent.o lib/schevo/store/_s_persistent.c:8:27: fatal error: weakrefobject.h: No such file or directory #include "weakrefobject.h" ^ compilation terminated. error: command 'cc' failed with exit status 1
Will need to investigate further why weakrefobject.h is missing from PyPy or find a workaround.
Best Regards,
Etienne
On 13/10/17 01:16 AM, Yury V. Zaytsev wrote:
You are using very outdated versions of both PyPy (latest = 5.9.0) and Cython (latest = 0.27.1), could you please try again with the latest versions? There have been a lot of compatibility work going on both sides, and it is not unlikely that the issue has been fixed in the meantime.
_______________________________________________ pypy-dev mailing list pypy-dev@python.org https://mail.python.org/mailman/listinfo/pypy-dev
-- Etienne Robillard tkadm30@yandex.com http://www.isotopesoftware.ca/

I opened a ticket for this issue: https://bitbucket.org/pypy/pypy/issues/2681/typeerror-__weakref__-slot-disal... Etienne Le 2017-10-13 à 08:13, Etienne Robillard a écrit :
Traceback (most recent call last): File "/usr/local/pypy/pypy2-v5.9.0-linux32/lib-python/2.7/wsgiref/handlers.py", line 85, in run self.result = application(self.environ, self.start_response) File "/usr/local/pypy/pypy2-v5.9.0-linux32/lib-python/2.7/wsgiref/validate.py", line 176, in lint_app iterator = application(environ, start_response_wrapper) File "/home/erob/src/django-hotsauce-oauthclient/lib/wsgi_oauth2/middleware.py", line 292, in __call__ return self.application(environ, start_response) File "lib/notmm/controllers/wsgi.pyx", line 136, in notmm.controllers.wsgi.BaseController.__call__ TypeError: __weakref__ slot disallowed: we already got one
-- Etienne Robillard tkadm30@yandex.com http://www.isotopesoftware.ca/

Hi Jason, How would you tackle this issue? I may not have defined any __slots__ in my code. Thank you in advance, Etienne Le 2017-10-13 à 11:18, Etienne Robillard a écrit :
I opened a ticket for this issue: https://bitbucket.org/pypy/pypy/issues/2681/typeerror-__weakref__-slot-disal...
Etienne
Le 2017-10-13 à 08:13, Etienne Robillard a écrit :
Traceback (most recent call last): File "/usr/local/pypy/pypy2-v5.9.0-linux32/lib-python/2.7/wsgiref/handlers.py", line 85, in run self.result = application(self.environ, self.start_response) File "/usr/local/pypy/pypy2-v5.9.0-linux32/lib-python/2.7/wsgiref/validate.py", line 176, in lint_app iterator = application(environ, start_response_wrapper) File "/home/erob/src/django-hotsauce-oauthclient/lib/wsgi_oauth2/middleware.py", line 292, in __call__ return self.application(environ, start_response) File "lib/notmm/controllers/wsgi.pyx", line 136, in notmm.controllers.wsgi.BaseController.__call__ TypeError: __weakref__ slot disallowed: we already got one
-- Etienne Robillard tkadm30@yandex.com http://www.isotopesoftware.ca/

Hi, I don't know anything near like enough about your code or environment to be able to make any productive suggestions. I left a comment on the issue with some ideas on where to look based on something I've seen in the distant past but that's about all I can do. (Oh, one other thing I would try if at all possible: Take Cython out of the mix and see what happens when you just run the code as pure Python.) Jason
On Oct 13, 2017, at 11:34, Etienne Robillard <tkadm30@yandex.com> wrote:
Hi Jason,
How would you tackle this issue?
I may not have defined any __slots__ in my code.
Thank you in advance, Etienne
Le 2017-10-13 à 11:18, Etienne Robillard a écrit :
I opened a ticket for this issue: https://bitbucket.org/pypy/pypy/issues/2681/typeerror-__weakref__-slot-disal...
Etienne
Le 2017-10-13 à 08:13, Etienne Robillard a écrit :
Traceback (most recent call last): File "/usr/local/pypy/pypy2-v5.9.0-linux32/lib-python/2.7/wsgiref/handlers.py", line 85, in run self.result = application(self.environ, self.start_response) File "/usr/local/pypy/pypy2-v5.9.0-linux32/lib-python/2.7/wsgiref/validate.py", line 176, in lint_app iterator = application(environ, start_response_wrapper) File "/home/erob/src/django-hotsauce-oauthclient/lib/wsgi_oauth2/middleware.py", line 292, in __call__ return self.application(environ, start_response) File "lib/notmm/controllers/wsgi.pyx", line 136, in notmm.controllers.wsgi.BaseController.__call__ TypeError: __weakref__ slot disallowed: we already got one
-- Etienne Robillard tkadm30@yandex.com http://www.isotopesoftware.ca/

Hi Jason, Thanks for writing. I fixed all the issues and everything seem to work so far. I'm going to add PyPy to the list of supported platforms for Django-hotsauce. :) Cheers, Etienne Le 2017-10-13 à 12:39, Jason Madden a écrit :
Hi,
I don't know anything near like enough about your code or environment to be able to make any productive suggestions. I left a comment on the issue with some ideas on where to look based on something I've seen in the distant past but that's about all I can do. (Oh, one other thing I would try if at all possible: Take Cython out of the mix and see what happens when you just run the code as pure Python.)
Jason
On Oct 13, 2017, at 11:34, Etienne Robillard <tkadm30@yandex.com> wrote:
Hi Jason,
How would you tackle this issue?
I may not have defined any __slots__ in my code.
Thank you in advance, Etienne
Le 2017-10-13 à 11:18, Etienne Robillard a écrit :
I opened a ticket for this issue: https://bitbucket.org/pypy/pypy/issues/2681/typeerror-__weakref__-slot-disal...
Etienne
Le 2017-10-13 à 08:13, Etienne Robillard a écrit :
Traceback (most recent call last): File "/usr/local/pypy/pypy2-v5.9.0-linux32/lib-python/2.7/wsgiref/handlers.py", line 85, in run self.result = application(self.environ, self.start_response) File "/usr/local/pypy/pypy2-v5.9.0-linux32/lib-python/2.7/wsgiref/validate.py", line 176, in lint_app iterator = application(environ, start_response_wrapper) File "/home/erob/src/django-hotsauce-oauthclient/lib/wsgi_oauth2/middleware.py", line 292, in __call__ return self.application(environ, start_response) File "lib/notmm/controllers/wsgi.pyx", line 136, in notmm.controllers.wsgi.BaseController.__call__ TypeError: __weakref__ slot disallowed: we already got one -- Etienne Robillard tkadm30@yandex.com http://www.isotopesoftware.ca/
-- Etienne Robillard tkadm30@yandex.com http://www.isotopesoftware.ca/

On Fri, 13 Oct 2017, Etienne Robillard wrote:
Thanks for writing. I fixed all the issues and everything seem to work so far. I'm going to add PyPy to the list of supported platforms for Django-hotsauce. :)
So, in the end, these issues were with your code, rather than PyPy / Cython? I think it would have been helpful if you gave a rundown of the problems you observed and how did you fix them... -- Sincerely yours, Yury V. Zaytsev

Hi Yuri I created a new branch for tracking my changes to django-hotsauce on PyPy: % hg clone -b 0.7-pypy https://bitbucket.org/tkadm30/django-hotsauce django-hotsauce Best Regards, Etienne Le 2017-10-13 à 15:13, Yury V. Zaytsev a écrit :
On Fri, 13 Oct 2017, Etienne Robillard wrote:
Thanks for writing. I fixed all the issues and everything seem to work so far. I'm going to add PyPy to the list of supported platforms for Django-hotsauce. :)
So, in the end, these issues were with your code, rather than PyPy / Cython? I think it would have been helpful if you gave a rundown of the problems you observed and how did you fix them...
-- Etienne Robillard tkadm30@yandex.com http://www.isotopesoftware.ca/
participants (3)
-
Etienne Robillard
-
Jason Madden
-
Yury V. Zaytsev