mirror of https://github.com/go-python/gopy.git
if renaming case, use lower-case string() method instead of String() -- fixes #337
This commit is contained in:
parent
4aba380925
commit
9dde3761d5
10
bind/gen.go
10
bind/gen.go
|
@ -863,3 +863,13 @@ func (g *pyGen) genGoPkg() {
|
|||
g.genType(sym, false, false) // not exttypes
|
||||
}
|
||||
}
|
||||
|
||||
// genStringerCall generates a call to either self.String() or self.string()
|
||||
// depending on RenameCase option
|
||||
func (g *pyGen) genStringerCall() {
|
||||
if g.cfg.RenameCase {
|
||||
g.pywrap.Printf("return self.string()\n")
|
||||
} else {
|
||||
g.pywrap.Printf("return self.String()\n")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -134,7 +134,7 @@ otherwise parameter is a python list that we copy from
|
|||
if isStringer(m.obj) {
|
||||
g.pywrap.Printf("def __str__(self):\n")
|
||||
g.pywrap.Indent()
|
||||
g.pywrap.Printf("return self.String()\n")
|
||||
g.genStringerCall()
|
||||
g.pywrap.Outdent()
|
||||
g.pywrap.Printf("\n")
|
||||
}
|
||||
|
|
|
@ -129,7 +129,7 @@ otherwise parameter is a python list that we copy from
|
|||
if isStringer(m.obj) {
|
||||
g.pywrap.Printf("def __str__(self):\n")
|
||||
g.pywrap.Indent()
|
||||
g.pywrap.Printf("return self.String()\n")
|
||||
g.genStringerCall()
|
||||
g.pywrap.Outdent()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -101,7 +101,7 @@ in which case a new Go object is constructed first
|
|||
}
|
||||
g.pywrap.Printf("def __str__(self):\n")
|
||||
g.pywrap.Indent()
|
||||
g.pywrap.Printf("return self.String()\n")
|
||||
g.genStringerCall()
|
||||
g.pywrap.Outdent()
|
||||
g.pywrap.Printf("\n")
|
||||
}
|
||||
|
@ -345,7 +345,7 @@ handle=A Go-side object is always initialized with an explicit handle=arg
|
|||
}
|
||||
g.pywrap.Printf("def __str__(self):\n")
|
||||
g.pywrap.Indent()
|
||||
g.pywrap.Printf("return self.String()\n")
|
||||
g.genStringerCall()
|
||||
g.pywrap.Outdent()
|
||||
g.pywrap.Printf("\n")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue