File tree 4 files changed +14
-4
lines changed
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() {
863
863
g .genType (sym , false , false ) // not exttypes
864
864
}
865
865
}
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
134
134
if isStringer (m .obj ) {
135
135
g .pywrap .Printf ("def __str__(self):\n " )
136
136
g .pywrap .Indent ()
137
- g .pywrap . Printf ( "return self.String() \n " )
137
+ g .genStringerCall ( )
138
138
g .pywrap .Outdent ()
139
139
g .pywrap .Printf ("\n " )
140
140
}
Original file line number Diff line number Diff line change @@ -129,7 +129,7 @@ otherwise parameter is a python list that we copy from
129
129
if isStringer (m .obj ) {
130
130
g .pywrap .Printf ("def __str__(self):\n " )
131
131
g .pywrap .Indent ()
132
- g .pywrap . Printf ( "return self.String() \n " )
132
+ g .genStringerCall ( )
133
133
g .pywrap .Outdent ()
134
134
}
135
135
}
Original file line number Diff line number Diff line change @@ -101,7 +101,7 @@ in which case a new Go object is constructed first
101
101
}
102
102
g .pywrap .Printf ("def __str__(self):\n " )
103
103
g .pywrap .Indent ()
104
- g .pywrap . Printf ( "return self.String() \n " )
104
+ g .genStringerCall ( )
105
105
g .pywrap .Outdent ()
106
106
g .pywrap .Printf ("\n " )
107
107
}
@@ -345,7 +345,7 @@ handle=A Go-side object is always initialized with an explicit handle=arg
345
345
}
346
346
g .pywrap .Printf ("def __str__(self):\n " )
347
347
g .pywrap .Indent ()
348
- g .pywrap . Printf ( "return self.String() \n " )
348
+ g .genStringerCall ( )
349
349
g .pywrap .Outdent ()
350
350
g .pywrap .Printf ("\n " )
351
351
}
You can’t perform that action at this time.
0 commit comments