This repository was archived by the owner on Nov 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 51
AttributeError: 'Candidate' object has no attribute '__unicode__' #317
Copy link
Copy link
Open
Labels
Description
To recreate:
from elex import api
e = api.Election(electiondate='2015-11-03', datafile=None, testresults=False, liveresults=True, is_test=False)
candidates = e.candidates
candidates
Traceback:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
~/venv-science/lib/python3.6/site-packages/IPython/core/formatters.py in __call__(self, obj)
700 type_pprinters=self.type_printers,
701 deferred_pprinters=self.deferred_printers)
--> 702 printer.pretty(obj)
703 printer.flush()
704 return stream.getvalue()
~/venv-science/lib/python3.6/site-packages/IPython/lib/pretty.py in pretty(self, obj)
381 if cls in self.type_pprinters:
382 # printer registered in self.type_pprinters
--> 383 return self.type_pprinters[cls](obj, self, cycle)
384 else:
385 # deferred printer
~/venv-science/lib/python3.6/site-packages/IPython/lib/pretty.py in inner(obj, p, cycle)
559 p.text(',')
560 p.breakable()
--> 561 p.pretty(x)
562 if len(obj) == 1 and type(obj) is tuple:
563 # Special case for 1-item tuples.
~/venv-science/lib/python3.6/site-packages/IPython/lib/pretty.py in pretty(self, obj)
398 if cls is not object \
399 and callable(cls.__dict__.get('__repr__')):
--> 400 return _repr_pprint(obj, self, cycle)
401
402 return _default_pprint(obj, self, cycle)
~/venv-science/lib/python3.6/site-packages/IPython/lib/pretty.py in _repr_pprint(obj, p, cycle)
693 """A pprint that just redirects to the normal repr function."""
694 # Find newlines and replace them with p.break_()
--> 695 output = repr(obj)
696 for idx,output_line in enumerate(output.splitlines()):
697 if idx:
~/venv-science/lib/python3.6/site-packages/elex/api/utils.py in __repr__(self)
26
27 def __repr__(self):
---> 28 return '<{}: {}>'.format(self.__class__.__name__, self.__str__())
29
30
~/venv-science/lib/python3.6/site-packages/elex/api/utils.py in <lambda>(x)
21 """
22 if sys.version_info > (3, 0):
---> 23 __str__ = lambda x: x.__unicode__()
24 else:
25 __str__ = lambda x: six.text_type(x).encode('utf-8')
AttributeError: 'Candidate' object has no attribute '__unicode__'