File tree 11 files changed +34
-35
lines changed
11 files changed +34
-35
lines changed Original file line number Diff line number Diff line change @@ -104,10 +104,8 @@ void main_thread_handler (gpointer user_data) {
104
104
for (ii = 0 ; ii < PyList_Size (syspath ); ++ ii ) {
105
105
const char * pydir = PyString_AsString (PyList_GetItem (syspath , ii ));
106
106
char * curdir = (char * ) malloc (1024 );
107
- if (strlen (pydir ) == 0 ) pydir = "." ;
108
-
109
- strcpy (curdir , pydir );
110
- strcat (curdir , slash );
107
+ strncpy (curdir , strlen (pydir ) > 0 ? pydir : "." , 1024 );
108
+ strncat (curdir , slash , 1024 );
111
109
112
110
//look in this directory for the pn_args->pr_file
113
111
DIR * dirp = opendir (curdir );
Original file line number Diff line number Diff line change @@ -77,9 +77,11 @@ internal static void Initialize() {
77
77
78
78
if ( 0 == Runtime . Py_IsInitialized ( ) ) {
79
79
Runtime . Py_Initialize ( ) ;
80
- Runtime . PyEval_InitThreads ( ) ;
81
80
}
82
81
82
+ // make sure threads are initialized even if python was initialized already
83
+ Runtime . PyEval_InitThreads ( ) ;
84
+
83
85
IntPtr dict = Runtime . PyImport_GetModuleDict ( ) ;
84
86
IntPtr op = Runtime . PyDict_GetItemString ( dict , "__builtin__" ) ;
85
87
Original file line number Diff line number Diff line change 9
9
10
10
using System ;
11
11
using System . Collections ;
12
- using System . Windows . Forms ;
13
12
using System . IO ;
14
13
15
14
namespace Python . Test {
@@ -53,9 +52,9 @@ public StructConstructorTest(Guid v) {
53
52
54
53
public class SubclassConstructorTest {
55
54
56
- public Control value ;
55
+ public Exception value ;
57
56
58
- public SubclassConstructorTest ( Control v ) {
57
+ public SubclassConstructorTest ( Exception v ) {
59
58
this . value = v ;
60
59
}
61
60
Original file line number Diff line number Diff line change @@ -88,4 +88,14 @@ public enum ULongEnum : ulong {
88
88
Five
89
89
}
90
90
91
+ [ FlagsAttribute ]
92
+ public enum FlagsEnum {
93
+ Zero ,
94
+ One ,
95
+ Two ,
96
+ Three ,
97
+ Four ,
98
+ Five
99
+ }
100
+
91
101
}
Original file line number Diff line number Diff line change @@ -57,6 +57,7 @@ public void Shutup() {
57
57
public decimal DecimalField = 0 ;
58
58
public string StringField ;
59
59
public ShortEnum EnumField ;
60
+ public FlagsEnum FlagsField ;
60
61
public object ObjectField ;
61
62
public ISpam SpamField ;
62
63
Original file line number Diff line number Diff line change 9
9
10
10
using System ;
11
11
using System . IO ;
12
- using System . Windows . Forms ;
13
12
using System . Collections . Generic ;
14
13
15
14
namespace Python . Test {
@@ -71,7 +70,7 @@ public Guid TestStructConversion(Guid v) {
71
70
return v ;
72
71
}
73
72
74
- public Control TestSubclassConversion ( Control v ) {
73
+ public Exception TestSubclassConversion ( Exception v ) {
75
74
return v ;
76
75
}
77
76
Original file line number Diff line number Diff line change @@ -49,14 +49,14 @@ def testStructConstructor(self):
49
49
def testSubclassConstructor (self ):
50
50
"""Test subclass constructor args"""
51
51
from Python .Test import SubclassConstructorTest
52
- from System .Windows .Forms import Form , Control
53
52
54
- class sub (Form ):
53
+ class sub (System . Exception ):
55
54
pass
56
55
57
- form = sub ()
58
- ob = SubclassConstructorTest (form )
59
- self .assertTrue (isinstance (ob .value , Control ))
56
+ instance = sub ()
57
+ ob = SubclassConstructorTest (instance )
58
+ print ob
59
+ self .assertTrue (isinstance (ob .value , System .Exception ))
60
60
61
61
62
62
Original file line number Diff line number Diff line change @@ -122,16 +122,13 @@ def test():
122
122
123
123
def testEnumWithFlagsAttrConversion (self ):
124
124
"""Test enumeration conversion with FlagsAttribute set."""
125
- from System .Windows .Forms import Label
126
-
127
- # This works because the AnchorStyles enum has FlagsAttribute.
128
- label = Label ()
129
- label .Anchor = 99
125
+ # This works because the FlagsField enum has FlagsAttribute.
126
+ Test .FieldTest ().FlagsField = 99
130
127
131
128
# This should fail because our test enum doesn't have it.
132
129
def test ():
133
130
Test .FieldTest ().EnumField = 99
134
-
131
+
135
132
self .assertRaises (ValueError , test )
136
133
137
134
Original file line number Diff line number Diff line change @@ -493,7 +493,6 @@ def testRandomMultipleHandlers(self):
493
493
494
494
def testRemoveInternalCallHandler (self ):
495
495
"""Test remove on an event sink implemented w/internalcall."""
496
- clr .AddReference ('System.Windows.Forms' )
497
496
object = EventTest ()
498
497
499
498
def h (sender , args ):
@@ -502,12 +501,6 @@ def h(sender, args):
502
501
object .PublicEvent += h
503
502
object .PublicEvent -= h
504
503
505
- from System .Windows .Forms import Form
506
- f = Form ()
507
- f .Click += h
508
- f .Click -= h
509
- f .Dispose ()
510
-
511
504
512
505
def testRemoveUnknownHandler (self ):
513
506
"""Test removing an event handler that was never added."""
Original file line number Diff line number Diff line change @@ -235,16 +235,13 @@ def testMethodCallStructConversion(self):
235
235
236
236
def testSubclassInstanceConversion (self ):
237
237
"""Test subclass instance conversion in method call."""
238
- clr .AddReference ("System.Windows.Forms" )
239
- from System .Windows .Forms import Form , Control
240
-
241
- class sub (Form ):
238
+ class sub (System .Exception ):
242
239
pass
243
240
244
241
object = MethodTest ()
245
- form = sub ()
246
- result = object .TestSubclassConversion (form )
247
- self .assertTrue (isinstance (result , Control ))
242
+ instance = sub ()
243
+ result = object .TestSubclassConversion (instance )
244
+ self .assertTrue (isinstance (result , System . Exception ))
248
245
249
246
250
247
def testNullArrayConversion (self ):
Original file line number Diff line number Diff line change @@ -204,6 +204,9 @@ def testFromModuleImportStar(self):
204
204
205
205
def testImplicitAssemblyLoad (self ):
206
206
"""Test implicit assembly loading via import."""
207
+ # this test only applies to windows
208
+ if sys .platform != "win32" :
209
+ return
207
210
208
211
def test ():
209
212
# This should fail until System.Windows.Forms has been
You can’t perform that action at this time.
0 commit comments