Index: b/src/modular/SGBase.i
===================================================================
--- a/src/modular/SGBase.i	2010-07-27 10:26:30.000000000 +0200
+++ b/src/modular/SGBase.i	2010-07-27 10:26:35.000000000 +0200
@@ -73,13 +73,15 @@
 %feature("unref") CSGObject "SG_UNREF($this);"
 
 %include <shogun/lib/common.h>
+
+%include "swig_typemaps.i"
+
 %include <shogun/lib/ShogunException.h>
 %include <shogun/lib/io.h>
 %include <shogun/base/SGObject.h>
 %include <shogun/base/Version.h>
 %include <shogun/base/Parallel.h>
 
-%include "swig_typemaps.i"
 
 
 %include stl.i
Index: b/src/python_modular/swig_typemaps.i
===================================================================
--- a/src/python_modular/swig_typemaps.i	2010-07-27 10:26:30.000000000 +0200
+++ b/src/python_modular/swig_typemaps.i	2010-07-27 10:26:35.000000000 +0200
@@ -74,18 +74,18 @@
  */
 
 const char* typecode_string(int typecode) {
-  const char* type_names[24] = {"bool","byte","unsigned byte","short",
-			  "unsigned short","int","unsigned int","long",
-              "unsigned long","long long", "unsigned long long",
-			  "float","double","long double",
-              "complex float","complex double","complex long double",
-			  "object","string","unicode","void","ntype","notype","char"};
-  const char* user_def="user defined";
-
-  if (typecode>24)
-      return user_def;
-  else
-      return type_names[typecode];
+    const char* type_names[24] = {"bool","byte","unsigned byte","short",
+        "unsigned short","int","unsigned int","long",
+        "unsigned long","long long", "unsigned long long",
+        "float","double","long double",
+        "complex float","complex double","complex long double",
+        "object","string","unicode","void","ntype","notype","char"};
+    const char* user_def="user defined";
+
+    if (typecode>24)
+        return user_def;
+    else
+        return type_names[typecode];
 }
 
 /* Make sure input has correct numeric type.  Allow character and byte
@@ -705,7 +705,12 @@
 #undef TYPEMAP_ARGOUT2
 
 /* Type mapping for grabbing a FILE * from Python */
-%typemap(in) FILE * {
+%typemap(typecheck, precedence=SWIG_TYPECHECK_POINTER) ( FILE* ) {
+    $1=0;
+    if (PyFile_Check($input))
+        $1=1;
+}
+%typemap(in) FILE* {
     if (!PyFile_Check($input)) {
         PyErr_SetString(PyExc_TypeError, "Need a file!");
         return NULL;
