@@ -113,33 +113,34 @@ public static IntPtr __import__(IntPtr self, IntPtr args, IntPtr kw) {
113
113
Runtime . Incref ( root . pyHandle ) ;
114
114
return root . pyHandle ;
115
115
}
116
- // 2010-08-15: Always seemed smart to let python try first...
117
- // This shaves off a few tenths of a second on test_module.py
118
- // and works around a quirk where 'sys' is found by the
119
- // LoadImplicit() deprecation logic.
120
- // Turns out that the AssemblyManager.ResolveHandler() checks to see if any
121
- // Assembly's FullName.ToLower().StartsWith(name.ToLower()), which makes very
122
- // little sense to me.
123
- IntPtr res = Runtime . PyObject_Call ( py_import , args , kw ) ;
124
- if ( res != IntPtr . Zero ) {
125
- // There was no error.
126
- return res ;
127
- }
128
- // There was an error
129
- if ( ! Exceptions . ExceptionMatches ( Exceptions . ImportError ) ) {
130
- // and it was NOT an ImportError; bail out here.
131
- return IntPtr . Zero ;
132
- }
133
- // Otherwise, just clear the it.
134
- Exceptions . Clear ( ) ;
135
-
136
116
string realname = mod_name ;
137
117
if ( mod_name . StartsWith ( "CLR." ) ) {
138
118
realname = mod_name . Substring ( 4 ) ;
139
119
string msg = String . Format ( "Importing from the CLR.* namespace " +
140
120
"is deprecated. Please import '{0}' directly." , realname ) ;
141
121
Exceptions . deprecation ( msg ) ;
142
122
}
123
+ else {
124
+ // 2010-08-15: Always seemed smart to let python try first...
125
+ // This shaves off a few tenths of a second on test_module.py
126
+ // and works around a quirk where 'sys' is found by the
127
+ // LoadImplicit() deprecation logic.
128
+ // Turns out that the AssemblyManager.ResolveHandler() checks to see if any
129
+ // Assembly's FullName.ToLower().StartsWith(name.ToLower()), which makes very
130
+ // little sense to me.
131
+ IntPtr res = Runtime . PyObject_Call ( py_import , args , kw ) ;
132
+ if ( res != IntPtr . Zero ) {
133
+ // There was no error.
134
+ return res ;
135
+ }
136
+ // There was an error
137
+ if ( ! Exceptions . ExceptionMatches ( Exceptions . ImportError ) ) {
138
+ // and it was NOT an ImportError; bail out here.
139
+ return IntPtr . Zero ;
140
+ }
141
+ // Otherwise, just clear the it.
142
+ Exceptions . Clear ( ) ;
143
+ }
143
144
144
145
string [ ] names = realname . Split ( '.' ) ;
145
146
0 commit comments