Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0fdb80a

Browse files
committed
Rename internal methods to proper Python API name
- PyUnicode_FromKindAndString to PyUnicode_FromKindAndData - PyString_AS_STRING to PyString_AsString
1 parent 464080f commit 0fdb80a

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

src/runtime/converter.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ private static bool ToPrimitive(IntPtr value, Type obType, out object result, bo
498498
{
499499
if (Runtime.PyString_Size(value) == 1)
500500
{
501-
op = Runtime.PyString_AS_STRING(value);
501+
op = Runtime.PyString_AsString(value);
502502
result = (byte)Marshal.ReadByte(op);
503503
return true;
504504
}
@@ -543,7 +543,7 @@ private static bool ToPrimitive(IntPtr value, Type obType, out object result, bo
543543
{
544544
if (Runtime.PyString_Size(value) == 1)
545545
{
546-
op = Runtime.PyString_AS_STRING(value);
546+
op = Runtime.PyString_AsString(value);
547547
result = (sbyte)Marshal.ReadByte(op);
548548
return true;
549549
}
@@ -588,7 +588,7 @@ private static bool ToPrimitive(IntPtr value, Type obType, out object result, bo
588588
{
589589
if (Runtime.PyString_Size(value) == 1)
590590
{
591-
op = Runtime.PyString_AS_STRING(value);
591+
op = Runtime.PyString_AsString(value);
592592
result = (char)Marshal.ReadByte(op);
593593
return true;
594594
}

src/runtime/runtime.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,8 +1243,8 @@ int size
12431243
[DllImport(PythonDll)]
12441244
internal static extern IntPtr PyString_FromStringAndSize(string value, int size);
12451245

1246-
[DllImport(PythonDll, EntryPoint = "PyString_AsString")]
1247-
internal static extern IntPtr PyString_AS_STRING(IntPtr op);
1246+
[DllImport(PythonDll)]
1247+
internal static extern IntPtr PyString_AsString(IntPtr op);
12481248

12491249
[DllImport(PythonDll)]
12501250
internal static extern int PyString_Size(IntPtr pointer);
@@ -1262,16 +1262,16 @@ internal static bool PyUnicode_Check(IntPtr ob)
12621262
[DllImport(PythonDll)]
12631263
internal static extern IntPtr PyUnicode_FromEncodedObject(IntPtr ob, IntPtr enc, IntPtr err);
12641264

1265-
[DllImport(PythonDll, EntryPoint = "PyUnicode_FromKindAndData")]
1266-
internal static extern IntPtr PyUnicode_FromKindAndString(
1265+
[DllImport(PythonDll)]
1266+
internal static extern IntPtr PyUnicode_FromKindAndData(
12671267
int kind,
12681268
[MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(StrMarshaler))] string s,
12691269
int size
12701270
);
12711271

12721272
internal static IntPtr PyUnicode_FromUnicode(string s, int size)
12731273
{
1274-
return PyUnicode_FromKindAndString(UCS, s, size);
1274+
return PyUnicode_FromKindAndData(UCS, s, size);
12751275
}
12761276

12771277
[DllImport(PythonDll)]
@@ -1330,7 +1330,7 @@ internal static string GetManagedString(IntPtr op)
13301330
#if PYTHON2 // Python 3 strings are all Unicode
13311331
if (type == PyStringType)
13321332
{
1333-
return Marshal.PtrToStringAnsi(PyString_AS_STRING(op), PyString_Size(op));
1333+
return Marshal.PtrToStringAnsi(PyString_AsString(op), PyString_Size(op));
13341334
}
13351335
#endif
13361336

src/runtime/typemanager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ internal static IntPtr AllocateTypeObject(string name)
415415
temp = Runtime.PyUnicode_FromString(name);
416416
#elif PYTHON2
417417
IntPtr temp = Runtime.PyString_FromString(name);
418-
IntPtr raw = Runtime.PyString_AS_STRING(temp);
418+
IntPtr raw = Runtime.PyString_AsString(temp);
419419
#endif
420420
Marshal.WriteIntPtr(type, TypeOffset.tp_name, raw);
421421
Marshal.WriteIntPtr(type, TypeOffset.name, temp);

0 commit comments

Comments
 (0)