diff options
author | cliechti <cliechti@f19166aa-fa4f-0410-85c2-fa1106f25c8a> | 2009-08-05 17:59:15 +0000 |
---|---|---|
committer | cliechti <cliechti@f19166aa-fa4f-0410-85c2-fa1106f25c8a> | 2009-08-05 17:59:15 +0000 |
commit | 1d133e2f8621fedefd35400f5744bbf1a65cb885 (patch) | |
tree | b9899eac98af3d1c16c502212d4bafb24dd83a8b /serial/__init__.py | |
parent | f1b1da2aa83e25e047c2607b6a0ece7bbb7c8ea9 (diff) | |
download | pyserial-1d133e2f8621fedefd35400f5744bbf1a65cb885.tar.gz |
fix when numbers are passed
git-svn-id: http://svn.code.sf.net/p/pyserial/code/trunk/pyserial@303 f19166aa-fa4f-0410-85c2-fa1106f25c8a
Diffstat (limited to 'serial/__init__.py')
-rw-r--r-- | serial/__init__.py | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/serial/__init__.py b/serial/__init__.py index 6874843..d7d968f 100644 --- a/serial/__init__.py +++ b/serial/__init__.py @@ -32,12 +32,20 @@ def serial_for_url(url, *args, **kwargs): # check remove extra parameter to not confuse the Serial class do_open = 'do_not_open' not in kwargs or not kwargs['do_not_open'] if 'do_not_open' in kwargs: del kwargs['do_not_open'] + # the default is to use the native version + klass = Serial # 'native' implementation # check port type and get class - if url.lower().startswith('rfc2217://'): - import rfc2217 # late import, so that users that don't use it don't have to load it - klass = rfc2217.Serial # RFC2217 implementation + try: + url_nocase = url.lower() + except AttributeError: + # its not a string, use default + pass else: - klass = Serial # 'native' implementation + if url_nocase.startswith('rfc2217://'): + import rfc2217 # late import, so that users that don't use it don't have to load it + klass = rfc2217.Serial # RFC2217 implementation + else: + klass = Serial # 'native' implementation # instantiate and open when desired instance = klass(None, *args, **kwargs) instance.port = url |