Merge pull request #21 from kouk/gitignore

Add a .gitignore to ignore a few common build artifacts.
diff --git a/OpenSSL/SSL.py b/OpenSSL/SSL.py
index ce2cc29..81ec2e2 100644
--- a/OpenSSL/SSL.py
+++ b/OpenSSL/SSL.py
@@ -1,11 +1,11 @@
-
+from sys import platform
 from functools import wraps, partial
 from itertools import count
 from weakref import WeakValueDictionary
 from errno import errorcode
 
 from six import text_type as _text_type
-
+from six import integer_types as integer_types
 
 from OpenSSL._util import (
     ffi as _ffi,
@@ -196,16 +196,15 @@
 
 def _asFileDescriptor(obj):
     fd = None
-
-    if not isinstance(obj, int):
+    if not isinstance(obj, integer_types):
         meth = getattr(obj, "fileno", None)
         if meth is not None:
             obj = meth()
 
-    if isinstance(obj, int):
+    if isinstance(obj, integer_types):
         fd = obj
 
-    if not isinstance(fd, int):
+    if not isinstance(fd, integer_types):
         raise TypeError("argument must be an int, or have a fileno() method.")
     elif fd < 0:
         raise ValueError(
@@ -856,8 +855,11 @@
         elif error == _lib.SSL_ERROR_SYSCALL:
             if _lib.ERR_peek_error() == 0:
                 if result < 0:
-                    raise SysCallError(
-                        _ffi.errno, errorcode[_ffi.errno])
+                    if platform == "win32":
+                        errno = _ffi.getwinerror()[0]
+                    else:
+                        errno = _ffi.errno
+                    raise SysCallError(errno, errorcode[errno])
                 else:
                     raise SysCallError(-1, "Unexpected EOF")
             else:
diff --git a/OpenSSL/test/test_ssl.py b/OpenSSL/test/test_ssl.py
index e366b47..e3518c5 100644
--- a/OpenSSL/test/test_ssl.py
+++ b/OpenSSL/test/test_ssl.py
@@ -6,7 +6,7 @@
 """
 
 from gc import collect, get_referrers
-from errno import ECONNREFUSED, EINPROGRESS, EWOULDBLOCK, EPIPE
+from errno import ECONNREFUSED, EINPROGRESS, EWOULDBLOCK, EPIPE, ESHUTDOWN
 from sys import platform, version_info
 from socket import SHUT_RDWR, error, socket
 from os import makedirs
@@ -1935,7 +1935,10 @@
         server, client = self._loopback()
         server.sock_shutdown(2)
         exc = self.assertRaises(SysCallError, server.sendall, b"hello, world")
-        self.assertEqual(exc.args[0], EPIPE)
+        if platform == "win32":
+            self.assertEqual(exc.args[0], ESHUTDOWN)
+        else:
+            self.assertEqual(exc.args[0], EPIPE)
 
 
 
diff --git a/OpenSSL/test/util.py b/OpenSSL/test/util.py
index 011e7da..4e4d812 100644
--- a/OpenSSL/test/util.py
+++ b/OpenSSL/test/util.py
@@ -17,7 +17,11 @@
 from OpenSSL._util import exception_from_error_queue
 from OpenSSL.crypto import Error
 
-import memdbg
+try:
+    import memdbg
+except Exception:
+    class _memdbg(object): heap = None
+    memdbg = _memdbg()
 
 from OpenSSL._util import ffi, lib, byte_string as b
 
diff --git a/runtests.py b/runtests.py
index 2ec425b..13f5c4c 100644
--- a/runtests.py
+++ b/runtests.py
@@ -2,7 +2,10 @@
 sys.modules['ssl'] = None
 sys.modules['_hashlib'] = None
 
-import memdbg
+try:
+   import memdbg
+except Exception as e:
+   pass
 
 from twisted.scripts.trial import run
 run()