An error occurs when trying printing a dict containing strings
Opened this issue · 2 comments
JustMegaAlex commented
My code
from beeprint import pp pp({1:'string'})
On running it i get an error:
Traceback (most recent call last):
File "/home/src/Coelus-LLC/coelus/work_2.py", line 13, in <module>
pp(nss)
File "/home/src/Coelus-LLC/coelus/.env/lib/python3.8/site-packages/beeprint/printer.py", line 66, in pp
res = str(Block(config, Context(obj=o)))
File "/home/src/Coelus-LLC/coelus/.env/lib/python3.8/site-packages/beeprint/models/block.py", line 42, in __str__
return self.build_block()
File "/home/src/Coelus-LLC/coelus/.env/lib/python3.8/site-packages/beeprint/models/block.py", line 142, in build_block
ret += str(ListBlock(self.config, self.ctx))
File "/home/src/Coelus-LLC/coelus/.env/lib/python3.8/site-packages/beeprint/models/block.py", line 42, in __str__
return self.build_block()
File "/home/src/Coelus-LLC/coelus/.env/lib/python3.8/site-packages/beeprint/models/block.py", line 372, in build_block
ret += str(Block(self.config, ctx))
File "/home/src/Coelus-LLC/coelus/.env/lib/python3.8/site-packages/beeprint/models/block.py", line 42, in __str__
return self.build_block()
File "/home/src/Coelus-LLC/coelus/.env/lib/python3.8/site-packages/beeprint/models/block.py", line 139, in build_block
ret += str(DictBlock(self.config, self.ctx))
File "/home/src/Coelus-LLC/coelus/.env/lib/python3.8/site-packages/beeprint/models/block.py", line 42, in __str__
return self.build_block()
File "/home/src/Coelus-LLC/coelus/.env/lib/python3.8/site-packages/beeprint/models/block.py", line 312, in build_block
ret += str(PairBlock(self.config, ctx))
File "/home/src/Coelus-LLC/coelus/.env/lib/python3.8/site-packages/beeprint/models/block.py", line 42, in __str__
return self.build_block()
File "/home/src/Coelus-LLC/coelus/.env/lib/python3.8/site-packages/beeprint/models/block.py", line 501, in build_block
ret += str(Block(self.config, ctx))
File "/home/src/Coelus-LLC/coelus/.env/lib/python3.8/site-packages/beeprint/models/block.py", line 42, in __str__
return self.build_block()
File "/home/src/Coelus-LLC/coelus/.env/lib/python3.8/site-packages/beeprint/models/block.py", line 139, in build_block
ret += str(DictBlock(self.config, self.ctx))
File "/home/src/Coelus-LLC/coelus/.env/lib/python3.8/site-packages/beeprint/models/block.py", line 42, in __str__
return self.build_block()
File "/home/src/Coelus-LLC/coelus/.env/lib/python3.8/site-packages/beeprint/models/block.py", line 312, in build_block
ret += str(PairBlock(self.config, ctx))
File "/home/src/Coelus-LLC/coelus/.env/lib/python3.8/site-packages/beeprint/models/block.py", line 42, in __str__
return self.build_block()
File "/home/src/Coelus-LLC/coelus/.env/lib/python3.8/site-packages/beeprint/models/block.py", line 501, in build_block
ret += str(Block(self.config, ctx))
File "/home/src/Coelus-LLC/coelus/.env/lib/python3.8/site-packages/beeprint/models/block.py", line 42, in __str__
return self.build_block()
File "/home/src/Coelus-LLC/coelus/.env/lib/python3.8/site-packages/beeprint/models/block.py", line 139, in build_block
ret += str(DictBlock(self.config, self.ctx))
File "/home/src/Coelus-LLC/coelus/.env/lib/python3.8/site-packages/beeprint/models/block.py", line 42, in __str__
return self.build_block()
File "/home/src/Coelus-LLC/coelus/.env/lib/python3.8/site-packages/beeprint/models/block.py", line 312, in build_block
ret += str(PairBlock(self.config, ctx))
File "/home/src/Coelus-LLC/coelus/.env/lib/python3.8/site-packages/beeprint/models/block.py", line 42, in __str__
return self.build_block()
File "/home/src/Coelus-LLC/coelus/.env/lib/python3.8/site-packages/beeprint/models/block.py", line 516, in build_block
ret += self.ctn.write(ustr(" ") + str(rb) + ustr(tail + block_ending))
File "/home/src/Coelus-LLC/coelus/.env/lib/python3.8/site-packages/beeprint/models/block.py", line 42, in __str__
return self.build_block()
File "/home/src/Coelus-LLC/coelus/.env/lib/python3.8/site-packages/beeprint/models/block.py", line 591, in build_block
return handler(self.ctx, self.typ)
File "/home/src/Coelus-LLC/coelus/.env/lib/python3.8/site-packages/beeprint/models/block.py", line 710, in __call__
return self.rearrenge(ctx, typ, wrapper)
File "/home/src/Coelus-LLC/coelus/.env/lib/python3.8/site-packages/beeprint/models/block.py", line 720, in rearrenge
left_margin = calc_left_margin(ctx, wrapper)
File "/home/src/Coelus-LLC/coelus/.env/lib/python3.8/site-packages/beeprint/helpers/string.py", line 54, in calc_left_margin
left_margin = calc_width(left_filling)
File "/home/src/Coelus-LLC/coelus/.env/lib/python3.8/site-packages/beeprint/helpers/string.py", line 17, in calc_width
return urwid.str_util.calc_width(s, 0, len(s))
AttributeError: module 'urwid' has no attribute 'str_util'
python 3.8.5
linux mint os
installed packages:
beeprint==2.4.10
urwid==2.1.2
P.s. i found a workaround just by by renaming urwid/old_str_utils.py to urwid/str_util
SmartManoj commented
@JustMegaAlex also propose a PR
fatemegh98 commented
Hi @JustMegaAlex
Can you tell me if you solved your issue? I have the same issue as you.