TypeError: '<=' not supported between instances of 'str' and 'int'

Bug #1798563 reported by Vincenzo
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Concurrent Log Handler for Python
New
Undecided
Unassigned

Bug Description

Using concurrentLogHandler v. 0.9.1 in python 3.6 (on Centos 7) I get the follow exception:

--- Logging error ---
Traceback (most recent call last):
  File "/usr/lib64/python3.6/logging/handlers.py", line 72, in emit
    self.doRollover()
  File "/home/bmlnx/.virtualenvs/librofirma/lib/python3.6/site-packages/cloghandler.py", line 261, in doRollover
    if self.backupCount <= 0:
TypeError: '<=' not supported between instances of 'str' and 'int'
Call stack:
  File "manage.py", line 25, in <module>
    execute_from_command_line(sys.argv)
  File "/home/bmlnx/.virtualenvs/librofirma/lib/python3.6/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
    utility.execute()
  File "/home/bmlnx/.virtualenvs/librofirma/lib/python3.6/site-packages/django/core/management/__init__.py", line 356, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/bmlnx/.virtualenvs/librofirma/lib/python3.6/site-packages/django/core/management/base.py", line 283, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/bmlnx/.virtualenvs/librofirma/lib/python3.6/site-packages/django/core/management/base.py", line 330, in execute
    output = self.handle(*args, **options)
  File "/home/bmlnx/.virtualenvs/librofirma/lib/python3.6/site-packages/django/core/management/commands/shell.py", line 108, in handle
    return getattr(self, shell)(options)
  File "/home/bmlnx/.virtualenvs/librofirma/lib/python3.6/site-packages/django/core/management/commands/shell.py", line 83, in python
    code.interact(local=imported_objects)
  File "/usr/lib64/python3.6/code.py", line 302, in interact
    console.interact(banner, exitmsg)
  File "/usr/lib64/python3.6/code.py", line 233, in interact
    more = self.push(line)
  File "/usr/lib64/python3.6/code.py", line 259, in push
    more = self.runsource(source, self.filename)
  File "/usr/lib64/python3.6/code.py", line 75, in runsource
    self.runcode(code)
  File "/usr/lib64/python3.6/code.py", line 91, in runcode
    exec(code, self.locals)
  File "<console>", line 1, in <module>
  File "/home/bmlnx/.virtualenvs/librofirma/lib/python3.6/site-packages/django/db/models/query.py", line 226, in __repr__
    data = list(self[:REPR_OUTPUT_SIZE + 1])
  File "/home/bmlnx/.virtualenvs/librofirma/lib/python3.6/site-packages/django/db/models/query.py", line 250, in __iter__
    self._fetch_all()
  File "/home/bmlnx/.virtualenvs/librofirma/lib/python3.6/site-packages/django/db/models/query.py", line 1118, in _fetch_all
    self._result_cache = list(self._iterable_class(self))
  File "/home/bmlnx/.virtualenvs/librofirma/lib/python3.6/site-packages/django/db/models/query.py", line 53, in __iter__
    results = compiler.execute_sql(chunked_fetch=self.chunked_fetch)
  File "/home/bmlnx/.virtualenvs/librofirma/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 889, in execute_sql
    cursor.execute(sql, params)
  File "/home/bmlnx/.virtualenvs/librofirma/lib/python3.6/site-packages/django/db/backends/utils.py", line 90, in execute
    extra={'duration': duration, 'sql': sql, 'params': params}
Message: '(%.3f) %s; args=%s'

Debugging the project I've found the problem is in doRollover method (cloghandler.py) at the statement:
if self.backupCount <= 0:

I think the solution could be:
if int(self.backupCount) <= 0:

This exception raised because I've setted up the logger configuration 'backupCount' parameter as string: ('backupCount': '30',)
This is my fault, but forcing the type into integer could be useful to reduce errors like mine.

****
System details
OS: Centos 7
Python: 3.6
Library version: 0.9.1
Django: 1.11

****
Steps to reproduce the exception
In settings.py configure backupCount parameter as a string:
'backupCount': '30',

Revision history for this message
Vincenzo (vincenzomangia) wrote :

AS showed in the attached screenshot, even if the backupCount parameter is setted as integer at the BaseRotatingHandler class, on the emit method, the parameter self.backupCount is readed as str.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.