File tree Expand file tree Collapse file tree 4 files changed +14
-4
lines changed Expand file tree Collapse file tree 4 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -863,3 +863,13 @@ func (g *pyGen) genGoPkg() {
863863 g .genType (sym , false , false ) // not exttypes
864864 }
865865}
866+
867+ // genStringerCall generates a call to either self.String() or self.string()
868+ // depending on RenameCase option
869+ func (g * pyGen ) genStringerCall () {
870+ if g .cfg .RenameCase {
871+ g .pywrap .Printf ("return self.string()\n " )
872+ } else {
873+ g .pywrap .Printf ("return self.String()\n " )
874+ }
875+ }
Original file line number Diff line number Diff line change @@ -134,7 +134,7 @@ otherwise parameter is a python list that we copy from
134134 if isStringer (m .obj ) {
135135 g .pywrap .Printf ("def __str__(self):\n " )
136136 g .pywrap .Indent ()
137- g .pywrap . Printf ( "return self.String() \n " )
137+ g .genStringerCall ( )
138138 g .pywrap .Outdent ()
139139 g .pywrap .Printf ("\n " )
140140 }
Original file line number Diff line number Diff line change @@ -129,7 +129,7 @@ otherwise parameter is a python list that we copy from
129129 if isStringer (m .obj ) {
130130 g .pywrap .Printf ("def __str__(self):\n " )
131131 g .pywrap .Indent ()
132- g .pywrap . Printf ( "return self.String() \n " )
132+ g .genStringerCall ( )
133133 g .pywrap .Outdent ()
134134 }
135135 }
Original file line number Diff line number Diff line change @@ -101,7 +101,7 @@ in which case a new Go object is constructed first
101101 }
102102 g .pywrap .Printf ("def __str__(self):\n " )
103103 g .pywrap .Indent ()
104- g .pywrap . Printf ( "return self.String() \n " )
104+ g .genStringerCall ( )
105105 g .pywrap .Outdent ()
106106 g .pywrap .Printf ("\n " )
107107 }
@@ -345,7 +345,7 @@ handle=A Go-side object is always initialized with an explicit handle=arg
345345 }
346346 g .pywrap .Printf ("def __str__(self):\n " )
347347 g .pywrap .Indent ()
348- g .pywrap . Printf ( "return self.String() \n " )
348+ g .genStringerCall ( )
349349 g .pywrap .Outdent ()
350350 g .pywrap .Printf ("\n " )
351351 }
You can’t perform that action at this time.
0 commit comments