From daca050962952ddbfa3696eebf49696537db1e06 Mon Sep 17 00:00:00 2001 From: Per Cederqvist Date: Fri, 10 Jun 2022 10:45:02 +0200 Subject: [PATCH 1/2] Fix Python 3 'urllib' error message When using Python 3.9.7, simply starting pyShell() produces this error message: AttributeError: module 'urllib' has no attribute 'request' Fix, by importing urllib.request before attempting to use urllib.request.urlopen. --- pyShelly/compat.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pyShelly/compat.py b/pyShelly/compat.py index 3c20249..9c4ded0 100644 --- a/pyShelly/compat.py +++ b/pyShelly/compat.py @@ -25,6 +25,8 @@ def urlencode(x): def urlopen(x): return urllib2.urlopen(x) else: + import urllib.request + def ba2c(x): # Convert bytearra to compatible bytearray return x From 5d6f979b2392e0dab85596dc7881abfaee42a37b Mon Sep 17 00:00:00 2001 From: Per Cederqvist Date: Fri, 3 Nov 2023 15:00:18 +0100 Subject: [PATCH 2/2] Update pyShelly/compat.py Co-authored-by: Andreas Motl --- pyShelly/compat.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pyShelly/compat.py b/pyShelly/compat.py index 9c4ded0..1f800a7 100644 --- a/pyShelly/compat.py +++ b/pyShelly/compat.py @@ -25,6 +25,7 @@ def urlencode(x): def urlopen(x): return urllib2.urlopen(x) else: + import urllib.parse import urllib.request def ba2c(x): # Convert bytearra to compatible bytearray