Thursday, October 26, 2017

Null characters in SQL query after having migrated to python 3.5.3

Hi,

I successfully ported Django 1.4.22 to Python 3.5.3.

However, I'm getting a unexpected issue when attempting to fetch a new
session key with the
_get_new_session_key() function.

Environment:


Request Method: GET
Request URL: http://localhost:8133/admin/

Django Version: 1.4.22
Python Version: 3.5.3
Installed Applications:
('django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sitemaps',
'django.contrib.sites',
'django.contrib.staticfiles',
'satchmo_admin',
'sorl.thumbnail',
'keyedcache',
'livesettings',
'l10n',
'satchmo_utils.thumbnail',
'satchmo_store.contact',
'satchmo_store.shop',
'satchmo_store',
'tax',
'tax.modules.no',
'tax.modules.area',
'tax.modules.percent',
'shipping',
'product',
'payment',
'payment.modules.dummy',
'payment.modules.paypal',
'shipping',
'satchmo_utils',
'app_plugins',
'billing')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.middleware.doc.XViewMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'threaded_multihost.middleware.ThreadLocalMiddleware')


Traceback:
File "/home/erob/src/django-hotsauce-devel/lib/notmm/adapters/base.py"
in get_response
190. response = middleware_method(request, response)
File
"/home/erob/src/django-livestore/contrib/django-1.4/django/contrib/sessions/middleware.py"
in process_response
44. request.session.save()
File
"/home/erob/src/django-livestore/contrib/django-1.4/django/contrib/sessions/backends/db.py"
in save
50. return self.create()
File
"/home/erob/src/django-livestore/contrib/django-1.4/django/contrib/sessions/backends/db.py"
in create
31. self._session_key = self._get_new_session_key()
File
"/home/erob/src/django-livestore/contrib/django-1.4/django/contrib/sessions/backends/base.py"
in _get_new_session_key
146. if not self.exists(session_key):
File
"/home/erob/src/django-livestore/contrib/django-1.4/django/contrib/sessions/backends/db.py"
in exists
27. return
Session.objects.filter(session_key=session_key).exists()
File
"/home/erob/src/django-livestore/contrib/django-1.4/django/db/models/query.py"
in exists
565. return self.query.has_results(using=self.db)
File
"/home/erob/src/django-livestore/contrib/django-1.4/django/db/models/sql/query.py"
in has_results
441. return bool(compiler.execute_sql(SINGLE))
File
"/home/erob/src/django-livestore/contrib/django-1.4/django/db/models/sql/compiler.py"
in execute_sql
818. cursor.execute(sql, params)
File
"/home/erob/src/django-livestore/contrib/django-1.4/django/db/backends/util.py"
in execute
40. return self.cursor.execute(sql, params)
File
"/home/erob/src/django-livestore/contrib/django-1.4/django/db/backends/sqlite3/base.py"
in execute
344. return Database.Cursor.execute(self, query, params)

Exception Type: ValueError at /admin/
Exception Value: the query contains a null character

The sql query is:

('SELECT (\x00) AS "a" FROM "django_session" WHERE '
'"django_session"."session_key" = ? LIMIT 1')

And the session_key param is: '22fc98168d24a14fe40a3e8956d818ad'


Any idea how to remove the null character (\x00) from the query?

TIA,

Etienne

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/03fadef0-72bf-4d7e-7b9c-45ca9077dd02%40yandex.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment