Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 44660

Summary: emerge -epv stops because format_size does not handle long totalsize correctly
Product: Portage Development Reporter: Hwang Joonhyung <envia>
Component: Core - Interface (emerge)Assignee: Portage team <dev-portage>
Status: RESOLVED FIXED    
Severity: normal Keywords: InVCS
Priority: High    
Version: unspecified   
Hardware: All   
OS: All   
Whiteboard:
Package list:
Runtime testing required: ---

Description Hwang Joonhyung 2004-03-14 04:55:02 UTC
I have installed lots of packages. When I try emerge -epv world, emerge crashes after printing list of packages to install.

Reproducible: Always
Steps to Reproduce:
1.Install lots of packages
2.emerge -epv
3.emerge -epv stops!

Actual Results:  
Traceback (most recent call last):
  File "/usr/bin/emerge", line 2578, in ?
    mydepgraph.display(mydepgraph.altlist())
  File "/usr/bin/emerge", line 1374, in display
    print "Total size of downloads: "+format_size(totalsize)
TypeError: cannot concatenate 'str' and 'long' objects


Expected Results:  
...
[ebuild  N    ] dev-games/kyra-2.0.7  +doc +opengl  1,947 kB
 
Total size of downloads: 2,495,198 kB
 
envia root #


Let's see format_size in /usr/bin/emerge...

def format_size(mysize):
        if type(mysize) != types.IntType:
                return mysize
        mystr=str(mysize/1024)
        mycount=len(mystr)
        while (mycount > 3):
                mycount-=3
                mystr=mystr[:mycount]+","+mystr[mycount:]
        return mystr+" kB"

Since I installed a lot, mysize became a long. And format_size returned long
(mysize). long and string cannot be concatenated!

LINE 1374
print "Total size of downloads: "+format_size(totalsize)

So format_size should handle long. Here's my fix.

----

--- /usr/bin/emerge     2004-03-14 21:51:45.000000000 +0900
+++ emerge      2004-03-14 21:50:34.302455288 +0900
@@ -320,7 +320,7 @@
  
 # formats a size given in bytes nicely
 def format_size(mysize):
-       if type(mysize) != types.IntType:
+       if type(mysize) != types.IntType and type(mysize) != types.LongType:
                return mysize
        mystr=str(mysize/1024)
        mycount=len(mystr)

----

Happy Hacking!
Comment 1 Marius Mauch (RETIRED) gentoo-dev 2004-03-14 06:49:57 UTC
Already fixed in CVS a few days ago :)
Comment 2 Brian Harring (RETIRED) gentoo-dev 2004-08-16 11:19:50 UTC
Closing (it's fixed in .51).
Still an issue in .50, although there is another bug open about it.