From ff27e3c8ba32a9c3cd3beef4df491f61046d8a55 Mon Sep 17 00:00:00 2001 From: Michael Buesch Date: Sat, 5 Dec 2015 21:01:08 +0100 Subject: [PATCH] socket: Add socket.error Older CPython versions raised socker.error (or classes derived from it) as exceptions on errors. Various software still uses it to be compatible with older Python versions. As it's one-line fix, allow MicroPython to run such code too. try: socket... except socker.error as e: ... --- socket/metadata.txt | 2 +- socket/setup.py | 2 +- socket/socket.py | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/socket/metadata.txt b/socket/metadata.txt index 617aff36..690d4565 100644 --- a/socket/metadata.txt +++ b/socket/metadata.txt @@ -1,4 +1,4 @@ srctype = micropython-lib type = module -version = 0.3.2 +version = 0.3.3 author = Paul Sokolovsky diff --git a/socket/setup.py b/socket/setup.py index 9126c238..887a8109 100644 --- a/socket/setup.py +++ b/socket/setup.py @@ -6,7 +6,7 @@ from setuptools import setup setup(name='micropython-socket', - version='0.3.2', + version='0.3.3', description='socket module for MicroPython', long_description="This is a module reimplemented specifically for MicroPython standard library,\nwith efficient and lean design in mind. Note that this module is likely work\nin progress and likely supports just a subset of CPython's corresponding\nmodule. Please help with the development if you are interested in this\nmodule.", url='https://github.com/micropython/micropython/issues/405', diff --git a/socket/socket.py b/socket/socket.py index fee54157..c07ce346 100644 --- a/socket/socket.py +++ b/socket/socket.py @@ -7,6 +7,8 @@ IPPROTO_IP = 0 IP_ADD_MEMBERSHIP = 35 IP_DROP_MEMBERSHIP = 36 +error = OSError + def _resolve_addr(addr): if isinstance(addr, (bytes, bytearray)): return addr