[issue37397] Trap in Python 3.5 under Apache 2.2 when Django database returns 'None'.

JOMO WILLACY report at bugs.python.org
Mon Jun 24 22:29:17 EDT 2019


New submission from JOMO WILLACY <JOMO_WILLACY at HOTMAIL.COM>:

I am using Python 3.5 with Django and the Python web server and Apache 2.2 web server.
I am querying the database for a "drug_name" and an "insurer" - # and minimum "price".

Here is what works and what does not work

Valid Drug Name   Valid Insurer     Works    Python web Server  Apache

Epipen               2               Yes        Yes               Yes

Lisenopril           2               Yes        Yes               Yes

Naftin               7               Yes        Yes               Yes



Invalid Drug Name    Insurer          Works     Python Server   Apache

Licenopril                            Yes        Yes              Yes

Licenopril             2                         Yes              No


In the last case up above it traps and the server logs at /var/www/logs/error.log say "Unhandled Exception".

This is where it traps ans what it says :

 Cannot convert str to float  :  'None'

File "/usr/local/lib64/python3.5/site-packages/django/db/models/fields/__init__.py"  line 1747, in get_prep_value

   return float( output_value )


I then went into the file where the trap occurred and I added a try catch like the function after line 1747 and the problem went away.

The trap only happens under Apache.

If you wish to reproduce this problem then go to these links and try the input listed above :

Python Web Server :

   http://34.200.216.166:8000/health_insurer2/minimum_price_for_drug/


Apache Web Server :

   http://34.200.216.166/health_insurer2/minimum_price_for_drug/


As an aid I have left debug=on in django so you will be able to trace the trap in the browser

The file that I am running is views.py
I am running Amazon AMI Linux in the cloud.


Sincerely Yours,


Jomo Willacy

----------
messages: 346476
nosy: jomo_willacy at hotmail.com
priority: normal
severity: normal
status: open
title: Trap in Python 3.5 under Apache 2.2 when Django database returns 'None'.
type: crash
versions: Python 3.5

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue37397>
_______________________________________


More information about the Python-bugs-list mailing list