8000 Revert previous commit "Add cleaunp to class info" · pythonnet/pythonnet@7e5ab52 · GitHub
[go: up one dir, main page]

Skip to content
65F2

Commit 7e5ab52

Browse files
committed
Revert previous commit "Add cleaunp to class info"
And change the scope of the ClassInfo class and add some documentation.
1 parent 639ba1f commit 7e5ab52

File tree

1 file changed

+14
-31
lines changed

1 file changed

+14
-31
lines changed

src/runtime/classmanager.cs

Lines changed: 14 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,8 @@ private static void InitClassBase(Type type, ClassBase impl)
215215
var item = (ManagedType)iter.Value;
216216
var name = (string)iter.Key;
217217
Runtime.PyDict_SetItemString(dict, name, item.pyHandle);
218+
// Decref the item now that it's been used.
219+
item.DecrRefCount();
218220
}
219221

220222
// If class has constructors, generate an __doc__ attribute.
@@ -461,41 +463,22 @@ private static ClassInfo GetClassInfo(Type type)
461463

462464
return ci;
463465
}
464-
}
465-
466-
467-
internal class ClassInfo : IDisposable
468-
{
469-
public Indexer indexer;
470-
public Hashtable members;
471-
472-
internal ClassInfo()
473-
{
474-
members = new Hashtable();
475-
indexer = null;
476-
}
477-
478-
~ClassInfo()
466+
467+
/// <summary>
468+
/// This class owns references to PyObjects in the `members` member.
469+
/// The caller has responsibility to DECREF them.
470+
/// </summary>
471+
private class ClassInfo
479472
{
480-
Dispose();
481-
}
482-
483-
private bool disposed = false;
473+
public Indexer indexer;
474+
public Hashtable members;
484475

485-
public void Dispose()
486-
{
487-
if (!disposed)
476+
internal ClassInfo()
488477
{
489-
disposed = true;
490-
foreach(DictionaryEntry member in members)
491-
{
492-
var item = (ManagedType)member.Value;
493-
if (item != null)
494-
{
495-
item.DecrRefCount();
496-
}
497-
}
478+
members = new Hashtable();
479+
indexer = null;
498480
}
499481
}
500482
}
483+
501484
}

0 commit comments

Comments
 (0)
0