[PyKDE] eric: Refactoring renaming bug

Parzival Herzog parzp at shaw.ca
Wed Oct 20 03:02:42 BST 2004


Eric seems to rename the wrong thing in some cases, when renaming a global 
variable.
.

I tried to rename the global "charmap" to "Charmap", by selecting
the first "charmap" in the snippet below, and using 
Refactoring/Refactoring/Rename:

Original code:

----------
charmap = ''.join(map(chr,range(1, maxchar)))

def encode(x, y, charmap=charmap):
    """ Compute a binary encoding of the difference between string x and
        string y.
    """
    if x == y:
        return ""
    if len(x) != len(y):
        return '\0' + y
    return b2c(_encode(x, y), charmap=charmap)
---------    


Result:

----------
Charmap = ''.join(map(chr,range(1, maxchar)))

def encode(x, y, Charmap=charmap):
    """ Compute a binary encoding of the difference between string x and
        string y.
    """
    if x == y:
        return ""
    if len(x) != len(y):
        return '\0' + y
    return b2c(_encode(x, y), charmap=charmap)
-----------


Notice that the formal parameter name is erroneously renamed, while the 
default value expression which refers to the renamed global is not altered.

There is also no undo for this change, and the file is altered, so the 
consequences of this bug could be difficult to reverse in some circumstances.


-- 
Parzival Herzog




More information about the PyQt mailing list