Python 3 issues

214 views
Skip to first unread message

Carlos Cesar Caballero Díaz

unread,
Apr 27, 2017, 1:04:17 AM4/27/17
to web2py-d...@googlegroups.com
Hi guys, following the last thread in the list about the status of
python 3 support, I began to test my apps using the master branch and
python 3, and they are working!!

The main problem right now is with the ldap authentication, because the
python-ldap module has no py3 version. I will try to fix it using a new
module, I find the ldap3 and the python-ldap3 modules that seems to suit
our needs (maybe there are others out there). Have you some
recommendation about that?

Right now I find other two issues, in some cases the tickets Traceback
shows: "no traceback because template parsing error", I need to check
the exact kind of errors that trigger this, and the other one is that my
apps are running 3 times slower with python3 using the default server.

Greetings.

Alexandre Andrade

unread,
Apr 27, 2017, 7:28:41 AM4/27/17
to web2py-d...@googlegroups.com
I also have noticed the 'templating error' in traceback. I wonder If the problem is in gluon/template.py itself or in the view that generate the traceback



--
-- mail from:GoogleGroups "web2py-developers" mailing list
make speech: web2py-developers@googlegroups.com
unsubscribe: web2py-developers+unsubscribe@googlegroups.com
details    : http://groups.google.com/group/web2py-developers
the project: http://code.google.com/p/web2py/
official    : http://www.web2py.com/
--- You received this message because you are subscribed to the Google Groups "web2py-developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Paolo Valleri

unread,
Apr 27, 2017, 11:58:50 AM4/27/17
to web2py-d...@googlegroups.com
A quick fix to overcome the 'templating error' is to remove the try/except in https://github.com/web2py/web2py/blob/master/gluon/restricted.py#L139. Post the output here

 Paolo

2017-04-27 13:28 GMT+02:00 Alexandre Andrade <alexand...@gmail.com>:
I also have noticed the 'templating error' in traceback. I wonder If the problem is in gluon/template.py itself or in the view that generate the traceback

Richard Vézina

unread,
Apr 27, 2017, 4:52:46 PM4/27/17
to web2py-d...@googlegroups.com
@Carlos, I think ldap3 is a good choice I recall trying it and I think that it design it more modern...

Richard

On Thu, Apr 27, 2017 at 11:58 AM, Paolo Valleri <paolo....@gmail.com> wrote:
A quick fix to overcome the 'templating error' is to remove the try/except in https://github.com/web2py/web2py/blob/master/gluon/restricted.py#L139. Post the output here

 Paolo

2017-04-27 13:28 GMT+02:00 Alexandre Andrade <alexand...@gmail.com>:
I also have noticed the 'templating error' in traceback. I wonder If the problem is in gluon/template.py itself or in the view that generate the traceback

Carlos Cesar Caballero Díaz

unread,
Apr 27, 2017, 8:20:42 PM4/27/17
to web2py-d...@googlegroups.com

Hi Paolo, thanks for your answer, this is the output:

Unhandled exception in thread started by <bound method Thread._bootstrap of <WSGIWorker(Thread-2, started daemon 140315953710848)>>
Traceback (most recent call last):
  File "/home/cccaballero/github/web2py/gluon/restricted.py", line 219, in restricted
    exec(ccode, environment)
  File "/home/cccaballero/github/web2py/applications/historia_clinica_new/models/0_db.py", line 94, in <module>
    from plugin_thumbnails.thumbnails import thumbnails
  File "/home/cccaballero/github/web2py/gluon/custom_import.py", line 77, in custom_importer
    return NATIVE_IMPORTER(oname, globals, locals, fromlist, level)
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 948, in _find_and_load_unlocked
KeyError: 'plugin_thumbnails'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/cccaballero/github/web2py/gluon/main.py", line 446, in wsgibase
    serve_controller(request, response, session)
  File "/home/cccaballero/github/web2py/gluon/main.py", line 177, in serve_controller
    run_models_in(environment)
  File "/home/cccaballero/github/web2py/gluon/compileapp.py", line 584, in run_models_in
    restricted(ccode, environment, layer=model)
  File "/home/cccaballero/github/web2py/gluon/restricted.py", line 233, in restricted
    raise RestrictedError(layer, ccode, output, environment)
  File "/home/cccaballero/github/web2py/gluon/restricted.py", line 143, in __init__
    self.traceback = traceback.format_exc()
  File "/usr/lib/python3.5/traceback.py", line 163, in format_exc
    return "".join(format_exception(*sys.exc_info(), limit=limit, chain=chain))
  File "/usr/lib/python3.5/traceback.py", line 117, in format_exception
    type(value), value, tb, limit=limit).format(chain=chain))
  File "/usr/lib/python3.5/traceback.py", line 474, in __init__
    capture_locals=capture_locals)
  File "/usr/lib/python3.5/traceback.py", line 358, in extract
    f.line
  File "/usr/lib/python3.5/traceback.py", line 282, in line
    self._line = linecache.getline(self.filename, self.lineno).strip()
AttributeError: 'NoneType' object has no attribute 'strip'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/cccaballero/github/web2py/gluon/rocket.py", line 1320, in run
    self.run_app(conn)
  File "/home/cccaballero/github/web2py/gluon/rocket.py", line 1821, in run_app
    output = self.app(environ, self.start_response)
  File "/home/cccaballero/github/web2py/gluon/main.py", line 651, in app_with_logging
    ret[0] = wsgiapp(environ, responder2)
  File "/home/cccaballero/github/web2py/gluon/main.py", line 546, in wsgibase
    e = RestrictedError('Framework', '', '', locals())
  File "/home/cccaballero/github/web2py/gluon/restricted.py", line 143, in __init__
    self.traceback = traceback.format_exc()
  File "/usr/lib/python3.5/traceback.py", line 163, in format_exc
    return "".join(format_exception(*sys.exc_info(), limit=limit, chain=chain))
  File "/usr/lib/python3.5/traceback.py", line 117, in format_exception
    type(value), value, tb, limit=limit).format(chain=chain))
  File "/usr/lib/python3.5/traceback.py", line 487, in __init__
    self._load_lines()
  File "/usr/lib/python3.5/traceback.py", line 500, in _load_lines
    self.__context__._load_lines()
  File "/usr/lib/python3.5/traceback.py", line 498, in _load_lines
    frame.line
  File "/usr/lib/python3.5/traceback.py", line 282, in line
    self._line = linecache.getline(self.filename, self.lineno).strip()
AttributeError: 'NoneType' object has no attribute 'strip'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
    self.run()
  File "/home/cccaballero/github/web2py/gluon/rocket.py", line 1323, in run
    handled = self._handleError(*exc)
  File "/home/cccaballero/github/web2py/gluon/rocket.py", line 1280, in _handleError
    tb_fmt = traceback.format_exception(typ, val, tb)
  File "/usr/lib/python3.5/traceback.py", line 117, in format_exception
    type(value), value, tb, limit=limit).format(chain=chain))
  File "/usr/lib/python3.5/traceback.py", line 487, in __init__
    self._load_lines()
  File "/usr/lib/python3.5/traceback.py", line 500, in _load_lines
    self.__context__._load_lines()
  File "/usr/lib/python3.5/traceback.py", line 500, in _load_lines
    self.__context__._load_lines()
  File "/usr/lib/python3.5/traceback.py", line 498, in _load_lines
    frame.line
  File "/usr/lib/python3.5/traceback.py", line 282, in line
    self._line = linecache.getline(self.filename, self.lineno).strip()
AttributeError: 'NoneType' object has no attribute 'strip'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.5/threading.py", line 882, in _bootstrap
    self._bootstrap_inner()
  File "/usr/lib/python3.5/threading.py", line 924, in _bootstrap_inner
    (self.name, _format_exc()), file=_sys.stderr)
  File "/usr/lib/python3.5/traceback.py", line 163, in format_exc
    return "".join(format_exception(*sys.exc_info(), limit=limit, chain=chain))
  File "/usr/lib/python3.5/traceback.py", line 117, in format_exception
    type(value), value, tb, limit=limit).format(chain=chain))
  File "/usr/lib/python3.5/traceback.py", line 487, in __init__
    self._load_lines()
  File "/usr/lib/python3.5/traceback.py", line 500, in _load_lines
    self.__context__._load_lines()
  File "/usr/lib/python3.5/traceback.py", line 500, in _load_lines
    self.__context__._load_lines()
  File "/usr/lib/python3.5/traceback.py", line 500, in _load_lines
    self.__context__._load_lines()
  File "/usr/lib/python3.5/traceback.py", line 498, in _load_lines
    frame.line
  File "/usr/lib/python3.5/traceback.py", line 282, in line
    self._line = linecache.getline(self.filename, self.lineno).strip()
AttributeError: 'NoneType' object has no attribute 'strip'



El 27/04/17 a las 11:58, Paolo Valleri escribió:
A quick fix to overcome the 'templating error' is to remove the try/except in https://github.com/web2py/web2py/blob/master/gluon/restricted.py#L139. Post the output here

 Paolo

2017-04-27 13:28 GMT+02:00 Alexandre Andrade <alexand...@gmail.com>:
I also have noticed the 'templating error' in traceback. I wonder If the problem is in gluon/template.py itself or in the view that generate the traceback
Em 27/04/2017 02:04, "Carlos Cesar Caballero Díaz" <carlos.caballero@cfg.jovenclub.cu> escreveu:
Hi guys, following the last thread in the list about the status of python 3 support, I began to test my apps using the master branch and python 3, and they are working!!

The main problem right now is with the ldap authentication, because the python-ldap module has no py3 version. I will try to fix it using a new module, I find the ldap3 and the python-ldap3 modules that seems to suit our needs (maybe there are others out there). Have you some recommendation about that?

Right now I find other two issues, in some cases the tickets Traceback shows: "no traceback because template parsing error", I need to check the exact kind of errors that trigger this, and the other one is that my apps are running 3 times slower with python3 using the default server.

Greetings.


--
-- mail from:GoogleGroups "web2py-developers" mailing list
make speech: web2py-developers@googlegroups.com
unsubscribe: web2py-developers+unsubscribe@googlegroups.com

the project: http://code.google.com/p/web2py/
official    : http://www.web2py.com/
--- You received this message because you are subscribed to the Google Groups "web2py-developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py-developers+unsubscribe@googlegroups.com.
--
-- mail from:GoogleGroups "web2py-developers" mailing list
make speech: web2py-developers@googlegroups.com
unsubscribe: web2py-developers+unsubscribe@googlegroups.com

the project: http://code.google.com/p/web2py/
official : http://www.web2py.com/
---
You received this message because you are subscribed to the Google Groups "web2py-developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py-developers+unsubscribe@googlegroups.com.
--
-- mail from:GoogleGroups "web2py-developers" mailing list

the project: http://code.google.com/p/web2py/
official : http://www.web2py.com/
---
You received this message because you are subscribed to the Google Groups "web2py-developers" group.

Carlos Cesar Caballero Díaz

unread,
Apr 27, 2017, 9:00:31 PM4/27/17
to web2py-d...@googlegroups.com

Thanks Richard, I think the same too, I will start working ASAP with ldap3.

Greetings.


El 27/04/17 a las 16:52, Richard Vézina escribió:
@Carlos, I think ldap3 is a good choice I recall trying it and I think that it design it more modern...

Richard
On Thu, Apr 27, 2017 at 11:58 AM, Paolo Valleri <paolo....@gmail.com> wrote:
A quick fix to overcome the 'templating error' is to remove the try/except in https://github.com/web2py/web2py/blob/master/gluon/restricted.py#L139. Post the output here

 Paolo

2017-04-27 13:28 GMT+02:00 Alexandre Andrade <alexand...@gmail.com>:
I also have noticed the 'templating error' in traceback. I wonder If the problem is in gluon/template.py itself or in the view that generate the traceback
Em 27/04/2017 02:04, "Carlos Cesar Caballero Díaz" <carlos.c...@cfg.jovenclub.cu> escreveu:
Hi guys, following the last thread in the list about the status of python 3 support, I began to test my apps using the master branch and python 3, and they are working!!

The main problem right now is with the ldap authentication, because the python-ldap module has no py3 version. I will try to fix it using a new module, I find the ldap3 and the python-ldap3 modules that seems to suit our needs (maybe there are others out there). Have you some recommendation about that?

Right now I find other two issues, in some cases the tickets Traceback shows: "no traceback because template parsing error", I need to check the exact kind of errors that trigger this, and the other one is that my apps are running 3 times slower with python3 using the default server.

Greetings.


--
-- mail from:GoogleGroups "web2py-developers" mailing list
make speech: web2py-developers@googlegroups.com
unsubscribe: web2py-developers+unsubscribe@googlegroups.com

the project: http://code.google.com/p/web2py/
official    : http://www.web2py.com/
--- You received this message because you are subscribed to the Google Groups "web2py-developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py-developers+unsubscribe@googlegroups.com.
--
-- mail from:GoogleGroups "web2py-developers" mailing list
make speech: web2py-developers@googlegroups.com
unsubscribe: web2py-developers+unsubscribe@googlegroups.com

the project: http://code.google.com/p/web2py/
official : http://www.web2py.com/
---
You received this message because you are subscribed to the Google Groups "web2py-developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py-developers+unsubscribe@googlegroups.com.
--
-- mail from:GoogleGroups "web2py-developers" mailing list
make speech: web2py-developers@googlegroups.com
unsubscribe: web2py-developers+unsubscribe@googlegroups.com

the project: http://code.google.com/p/web2py/
official : http://www.web2py.com/
---
You received this message because you are subscribed to the Google Groups "web2py-developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py-developers+unsubscribe@googlegroups.com.
--
-- mail from:GoogleGroups "web2py-developers" mailing list

the project: http://code.google.com/p/web2py/
official : http://www.web2py.com/
---
You received this message because you are subscribed to the Google Groups "web2py-developers" group.

Nico Zanferrari

unread,
Apr 28, 2017, 6:53:21 AM4/28/17
to web2py-d...@googlegroups.com
Hi, I've had the same problem as Carlos, but with the standard Welcome App ... see the attachment.

Nico


the project: http://code.google.com/p/web2py/
official : http://www.web2py.com/
---
You received this message because you are subscribed to the Google Groups "web2py-developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

traceback.txt

Michele Comitini

unread,
Apr 28, 2017, 7:07:48 AM4/28/17
to web2py-developers
@Carlos

The error seems related to a plugin: plugin_thumbnails.
Is that plugin py3 compatible?




 Paolo


the project: http://code.google.com/p/web2py/
official : http://www.web2py.com/
---
You received this message because you are subscribed to the Google Groups "web2py-developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Nico Zanferrari

unread,
Apr 28, 2017, 8:05:50 AM4/28/17
to web2py-d...@googlegroups.com
Looking better, I've found that my particular traceback is related to /applications/admin/controllers/default.py:plugins", line 1973 , and it raises also with python 2.7 when you click on the "Welcome" app --> This APP --> Design --> button "Download plugins from Repository" , that leads to 


If you are not connected to Internet you get the "TypeError: list indices must be integers or slices, not str" Error.


Apart from this particular type error, I think there is a general issue with Python 3: you cannot get a full traceback in the Web GUI ;-(

Cheers,
Nico

Paolo Valleri

unread,
Apr 28, 2017, 8:24:12 AM4/28/17
to web2py-d...@googlegroups.com
Nico, tickets work on py3 too. The problem is that you cannot pass from py27 to py35 and viceversa without cleaning sessions, errors etc.

 Paolo

Nico Zanferrari

unread,
Apr 28, 2017, 8:39:37 AM4/28/17
to web2py-d...@googlegroups.com
Ciao Paolo,

I know it: I run them on completely different folders (it should be enough, isn't it?). I'm attaching two screenshots of the same error that should explain it better ;-)

Also, the series of errors "During handling of the above exception, another exception occurred: ...." are showing on the console.
snapshot_27.png
snapshot_35.png

Massimo DiPierro

unread,
Apr 28, 2017, 9:03:10 AM4/28/17
to web2py-d...@googlegroups.com
I made a change to the custom import that should catch that error. It is strange that the native imported in python3 raises KeyError instead of ImportError. Now we catch them and let’s hope this is the only new error it can raise.

I am very puzzled by the second error. It is caused by traceback.format_exc() which is not our function and we pass no value to it.

Massimo


details : http://groups.google.com/group/web2py-developers
the project: http://code.google.com/p/web2py/
official : http://www.web2py.com/
---
You received this message because you are subscribed to the Google Groups "web2py-developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py-develop...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
<snapshot_27.png><snapshot_35.png>

Carlos Cesar Caballero Díaz

unread,
Apr 28, 2017, 11:29:55 AM4/28/17
to web2py-d...@googlegroups.com

no, the plugin is not python 3 compatible, but the issue is not related to the plugin, is related to the ticket traceback showing "no traceback because template parsing error"

Greetings.


El 28/04/17 a las 07:07, Michele Comitini escribió:

 Paolo


the project: http://code.google.com/p/web2py/
official    : http://www.web2py.com/
--- You received this message because you are subscribed to the Google Groups "web2py-developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py-developers+unsubscribe@googlegroups.com.
--
-- mail from:GoogleGroups "web2py-developers" mailing list
make speech: web2py-developers@googlegroups.com
unsubscribe: web2py-developers+unsubscribe@googlegroups.com

the project: http://code.google.com/p/web2py/
official : http://www.web2py.com/
---
You received this message because you are subscribed to the Google Groups "web2py-developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py-developers+unsubscribe@googlegroups.com.
--
-- mail from:GoogleGroups "web2py-developers" mailing list
make speech: web2py-developers@googlegroups.com
unsubscribe: web2py-developers+unsubscribe@googlegroups.com

the project: http://code.google.com/p/web2py/
official : http://www.web2py.com/
---
You received this message because you are subscribed to the Google Groups "web2py-developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py-developers+unsubscribe@googlegroups.com.
--
-- mail from:GoogleGroups "web2py-developers" mailing list
To unsubscribe from this group and stop receiving emails from it, send an email to web2py-develop...@googlegroups.com.

Richard Vézina

unread,
Apr 28, 2017, 11:55:53 AM4/28/17
to web2py-d...@googlegroups.com
Hello Carlos,

I don't know why your answer often pop out of thread, it makes difficults to follow... Are you using some kind of email software (example thunderbird)? If so, I know that "RE:" append to the email object does that... It can be fix by configuring the email software.

Regards

Richard



the project: http://code.google.com/p/web2py/
official : http://www.web2py.com/
---
You received this message because you are subscribed to the Google Groups "web2py-developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Carlos Cesar Caballero

unread,
May 1, 2017, 2:01:53 PM5/1/17
to web2py-developers
Hi Richard, I am using Thunderbird, but I am not sure what you mean because thunderbird shows the threads ok, can you send me a link or something about the issue and/or how to fix it?

Greetings.

Nico Zanferrari

unread,
May 2, 2017, 8:52:22 AM5/2/17
to web2py-d...@googlegroups.com
Hi Carlos,

I think that the problem comes from the addition of the {Disarmed} tag into the subject when you reply. This is probably added by your mail client or ISP, see http://forums.mozillazine.org/viewtopic.php?f=39&t=1604185 for example.
While this is silently hidden on the Goggle Groups at https://groups.google.com/forum/#!forum/web2py-developers, it breaks badly the thread on Goggle mail (at least as seen with the Web Mail interface).

nico

2017-05-01 20:01 GMT+02:00 Carlos Cesar Caballero <carlos.c...@cfg.jovenclub.cu>:
Hi Richard, I am using Thunderbird, but I am not sure what you mean because thunderbird shows the threads ok, can you send me a link or something about the issue and/or how to fix it?

Greetings.

--
-- mail from:GoogleGroups "web2py-developers" mailing list
make speech: web2py-developers@googlegroups.com
unsubscribe: web2py-developers+unsubscribe@googlegroups.com

Richard Vézina

unread,
May 2, 2017, 11:29:30 AM5/2/17
to web2py-d...@googlegroups.com
You go in the option on how to reply and remove anything that change the object of the emails you receive... If you can use Gmail, you will see what going on when you answer...

Thanks

Richard

On Tue, May 2, 2017 at 8:52 AM, Nico Zanferrari <nico...@gmail.com> wrote:
Hi Carlos,

I think that the problem comes from the addition of the {Disarmed} tag into the subject when you reply. This is probably added by your mail client or ISP, see http://forums.mozillazine.org/viewtopic.php?f=39&t=1604185 for example.
While this is silently hidden on the Goggle Groups at https://groups.google.com/forum/#!forum/web2py-developers, it breaks badly the thread on Goggle mail (at least as seen with the Web Mail interface).

nico

Richard Vézina

unread,
May 2, 2017, 11:38:25 AM5/2/17
to web2py-d...@googlegroups.com
Saddly I can't find any good tuto or documentation... But I recall it was obvious once in the configuration... Hope {Disarmed} don't get append by antivirus or other third party in the reply process... If so, you may consider changing the smtp server you use to reply, you can configure to use gmail one if you have anaccount.

Richard

On Tue, May 2, 2017 at 11:29 AM, Richard Vézina <ml.richa...@gmail.com> wrote:
You go in the option on how to reply and remove anything that change the object of the emails you receive... If you can use Gmail, you will see what going on when you answer...

Thanks

Richard
On Tue, May 2, 2017 at 8:52 AM, Nico Zanferrari <nico...@gmail.com> wrote:
Hi Carlos,

I think that the problem comes from the addition of the {Disarmed} tag into the subject when you reply. This is probably added by your mail client or ISP, see http://forums.mozillazine.org/viewtopic.php?f=39&t=1604185 for example.
While this is silently hidden on the Goggle Groups at https://groups.google.com/forum/#!forum/web2py-developers, it breaks badly the thread on Goggle mail (at least as seen with the Web Mail interface).

nico

Nico Zanferrari

unread,
May 3, 2017, 5:32:01 AM5/3/17
to web2py-d...@googlegroups.com
I've just opened an issue (https://github.com/web2py/web2py/issues/1621) in order to track the traceback.format_exc() error.

Cheers,
Nico

Massimo

<snapshot_27.png><snapshot_35.png>

Reply all
Reply to author
Forward
0 new messages