Skip to content

Commit a2e8d46

Browse files
committed
Replace PyString_FromStringAndSize usage to PyString_FromString
1 parent 310d50d commit a2e8d46

File tree

6 files changed

+7
-11
lines changed

6 files changed

+7
-11
lines changed

src/runtime/fieldobject.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,7 @@ public static IntPtr tp_descr_get(IntPtr ds, IntPtr ob, IntPtr tp)
136136
public static IntPtr tp_repr(IntPtr ob)
137137
{
138138
var self = (FieldObject)GetManagedObject(ob);
139-
string s = $"<field '{self.info.Name}'>";
140-
return Runtime.PyString_FromStringAndSize(s, s.Length);
139+
return Runtime.PyString_FromString($"<field '{self.info.Name}'>");
141140
}
142141
}
143142
}

src/runtime/methodbinding.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,8 @@ public static IntPtr tp_repr(IntPtr ob)
231231
{
232232
var self = (MethodBinding)GetManagedObject(ob);
233233
string type = self.target == IntPtr.Zero ? "unbound" : "bound";
234-
string s = string.Format("<{0} method '{1}'>", type, self.m.name);
235-
return Runtime.PyString_FromStringAndSize(s, s.Length);
234+
string name = self.m.name;
235+
return Runtime.PyString_FromString($"<{type} method '{name}'>");
236236
}
237237

238238
/// <summary>

src/runtime/methodobject.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,7 @@ public static IntPtr tp_descr_get(IntPtr ds, IntPtr ob, IntPtr tp)
187187
public static IntPtr tp_repr(IntPtr ob)
188188
{
189189
var self = (MethodObject)GetManagedObject(ob);
190-
string s = string.Format("<method '{0}'>", self.name);
191-
return Runtime.PyString_FromStringAndSize(s, s.Length);
190+
return Runtime.PyString_FromString($"<method '{self.name}'>");
192191
}
193192

194193
/// <summary>

src/runtime/modulefunctionobject.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ public static IntPtr tp_call(IntPtr ob, IntPtr args, IntPtr kw)
3333
public new static IntPtr tp_repr(IntPtr ob)
3434
{
3535
var self = (ModuleFunctionObject)GetManagedObject(ob);
36-
string s = $"<CLRModuleFunction '{self.name}'>";
37-
return Runtime.PyString_FromStringAndSize(s, s.Length);
36+
return Runtime.PyString_FromString($"<CLRModuleFunction '{self.name}'>");
3837
}
3938
}
4039
}

src/runtime/propertyobject.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,7 @@ public static IntPtr tp_descr_get(IntPtr ds, IntPtr ob, IntPtr tp)
158158
public static IntPtr tp_repr(IntPtr ob)
159159
{
160160
var self = (PropertyObject)GetManagedObject(ob);
161-
string s = $"<property '{self.info.Name}'>";
162-
return Runtime.PyString_FromStringAndSize(s, s.Length);
161+
return Runtime.PyString_FromString($"<property '{self.info.Name}'>");
163162
}
164163
}
165164
}

src/runtime/pyansistring.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public PyAnsiString(PyObject o)
4444
/// </remarks>
4545
public PyAnsiString(string s)
4646
{
47-
obj = Runtime.PyString_FromStringAndSize(s, s.Length);
47+
obj = Runtime.PyString_FromString(s);
4848
if (obj == IntPtr.Zero)
4949
{
5050
throw new PythonException();

0 commit comments

Comments
 (0)