Skip to content

Commit c2fa512

Browse files
committed
Merge remote-tracking branch 'origin/master' into moat
2 parents 0147697 + b379e4f commit c2fa512

File tree

14 files changed

+55
-23
lines changed

14 files changed

+55
-23
lines changed

micropython/aioespnow/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ A small async server example::
5555
import asyncio
5656

5757
# A WLAN interface must be active to send()/recv()
58-
network.WLAN(network.STA_IF).active(True)
58+
network.WLAN(network.WLAN.IF_STA).active(True)
5959

6060
e = aioespnow.AIOESPNow() # Returns AIOESPNow enhanced with async support
6161
e.active(True)

micropython/mip/manifest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
metadata(version="0.3.0", description="On-device package installer for network-capable boards")
1+
metadata(version="0.4.0", description="On-device package installer for network-capable boards")
22

33
require("requests")
44

micropython/mip/mip/__init__.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
_PACKAGE_INDEX = const("https://micropython.org/pi/v2")
1010
_CHUNK_SIZE = 128
1111

12+
allowed_mip_url_prefixes = ("http://", "https://", "github:", "gitlab:")
13+
1214

1315
# This implements os.makedirs(os.dirname(path))
1416
def _ensure_path_exists(path):
@@ -124,8 +126,12 @@ def _install_json(package_json_url, index, target, version, mpy):
124126
if not _download_file(file_url, fs_target_path):
125127
print("File not found: {} {}".format(target_path, short_hash))
126128
return False
129+
base_url = package_json_url.rpartition("/")[0]
127130
for target_path, url in package_json.get("urls", ()):
128131
fs_target_path = target + "/" + target_path
132+
is_full_url = any(url.startswith(p) for p in allowed_mip_url_prefixes)
133+
if base_url and not is_full_url:
134+
url = f"{base_url}/{url}" # Relative URLs
129135
if not _download_file(_rewrite_url(url, version), fs_target_path):
130136
print("File not found: {} {}".format(target_path, url))
131137
return False
@@ -136,12 +142,7 @@ def _install_json(package_json_url, index, target, version, mpy):
136142

137143

138144
def _install_package(package, index, target, version, mpy):
139-
if (
140-
package.startswith("http://")
141-
or package.startswith("https://")
142-
or package.startswith("github:")
143-
or package.startswith("gitlab:")
144-
):
145+
if any(package.startswith(p) for p in allowed_mip_url_prefixes):
145146
if package.endswith(".py") or package.endswith(".mpy"):
146147
print("Downloading {} to {}".format(package, target))
147148
return _download_file(

micropython/net/webrepl/webrepl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def setup_conn(port, accept_handler):
102102
listen_s.listen(1)
103103
if accept_handler:
104104
listen_s.setsockopt(socket.SOL_SOCKET, 20, accept_handler)
105-
for i in (network.AP_IF, network.STA_IF):
105+
for i in (network.WLAN.IF_AP, network.WLAN.IF_STA):
106106
iface = network.WLAN(i)
107107
if iface.active():
108108
print("WebREPL server started on http://%s:%d/" % (iface.ifconfig()[0], port))

micropython/umqtt.simple/manifest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
metadata(description="Lightweight MQTT client for MicroPython.", version="1.4.0")
1+
metadata(description="Lightweight MQTT client for MicroPython.", version="1.5.0")
22

33
# Originally written by Paul Sokolovsky.
44

micropython/umqtt.simple/umqtt/simple.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,9 @@ def set_last_will(self, topic, msg, retain=False, qos=0):
6060
self.lw_qos = qos
6161
self.lw_retain = retain
6262

63-
def connect(self, clean_session=True):
63+
def connect(self, clean_session=True, timeout=None):
6464
self.sock = socket.socket()
65+
self.sock.settimeout(timeout)
6566
addr = socket.getaddrinfo(self.server, self.port)[0][-1]
6667
self.sock.connect(addr)
6768
if self.ssl:

python-ecosys/requests/manifest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
metadata(version="0.10.0", pypi="requests")
1+
metadata(version="0.10.1", pypi="requests")
22

33
package("requests")

python-ecosys/requests/requests/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ def request(
4646
):
4747
if headers is None:
4848
headers = {}
49+
else:
50+
headers = headers.copy()
4951

5052
redirect = None # redirection url, None means no redirection
5153
chunked_data = data and getattr(data, "__next__", None) and not getattr(data, "__len__", None)

python-ecosys/requests/test_requests.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,11 @@ def chunks():
102102

103103
def test_overwrite_get_headers():
104104
response = requests.request(
105-
"GET", "http://example.com", headers={"Connection": "keep-alive", "Host": "test.com"}
105+
"GET", "http://example.com", headers={"Host": "test.com", "Connection": "keep-alive"}
106106
)
107107

108108
assert response.raw._write_buffer.getvalue() == (
109-
b"GET / HTTP/1.0\r\n" + b"Host: test.com\r\n" + b"Connection: keep-alive\r\n\r\n"
109+
b"GET / HTTP/1.0\r\n" + b"Connection: keep-alive\r\n" + b"Host: test.com\r\n\r\n"
110110
), format_message(response)
111111

112112

@@ -145,6 +145,14 @@ def chunks():
145145
), format_message(response)
146146

147147

148+
def test_do_not_modify_headers_argument():
149+
global do_not_modify_this_dict
150+
do_not_modify_this_dict = {}
151+
requests.request("GET", "http://example.com", headers=do_not_modify_this_dict)
152+
153+
assert do_not_modify_this_dict == {}, do_not_modify_this_dict
154+
155+
148156
test_simple_get()
149157
test_get_auth()
150158
test_get_custom_header()
@@ -153,3 +161,4 @@ def chunks():
153161
test_overwrite_get_headers()
154162
test_overwrite_post_json_headers()
155163
test_overwrite_post_chunked_data_headers()
164+
test_do_not_modify_headers_argument()

python-stdlib/unittest/manifest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
metadata(version="0.10.3")
1+
metadata(version="0.10.4")
22

33
package("unittest")

python-stdlib/unittest/tests/test_exception.py renamed to python-stdlib/unittest/tests/exception.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# This makes unittest return an error code, so is not named "test_xxx.py".
2+
13
import unittest
24

35

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import unittest
2+
3+
4+
class Test(unittest.TestCase):
5+
def test_subtest_skip(self):
6+
for i in range(4):
7+
with self.subTest(i=i):
8+
print("sub test", i)
9+
if i == 2:
10+
self.skipTest("skip 2")
11+
12+
13+
if __name__ == "__main__":
14+
unittest.main()

python-stdlib/unittest/unittest/__init__.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ def assertRaises(self, exc, func=None, *args, **kwargs):
198198
except Exception as e:
199199
if isinstance(e, exc):
200200
return
201-
raise
201+
raise e
202202

203203
assert False, "%r not raised" % exc
204204

@@ -348,7 +348,13 @@ def _handle_test_exception(
348348
exc = exc_info[1]
349349
traceback = exc_info[2]
350350
ex_str = _capture_exc(exc, traceback)
351-
if isinstance(exc, AssertionError):
351+
if isinstance(exc, SkipTest):
352+
reason = exc.args[0]
353+
test_result.skippedNum += 1
354+
test_result.skipped.append((current_test, reason))
355+
print(" skipped:", reason)
356+
return
357+
elif isinstance(exc, AssertionError):
352358
test_result.failuresNum += 1
353359
test_result.failures.append((current_test, ex_str))
354360
if verbose:
@@ -396,17 +402,12 @@ def run_one(test_function):
396402
print(" FAIL")
397403
else:
398404
print(" ok")
399-
except SkipTest as e:
400-
reason = e.args[0]
401-
print(" skipped:", reason)
402-
test_result.skippedNum += 1
403-
test_result.skipped.append((name, c, reason))
404405
except Exception as ex:
405406
_handle_test_exception(
406407
current_test=(name, c), test_result=test_result, exc_info=(type(ex), ex, None)
407408
)
408409
# Uncomment to investigate failure in detail
409-
# raise
410+
# raise ex
410411
finally:
411412
__test_result__ = None
412413
__current_test__ = None

tools/ci.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ function ci_package_tests_run {
6363
python-stdlib/os-path/test_path.py \
6464
python-stdlib/pickle/test_pickle.py \
6565
python-stdlib/string/test_translate.py \
66+
python-stdlib/unittest/tests/exception.py \
6667
unix-ffi/gettext/test_gettext.py \
6768
unix-ffi/pwd/test_getpwnam.py \
6869
unix-ffi/re/test_re.py \
@@ -90,6 +91,7 @@ function ci_package_tests_run {
9091
python-stdlib/shutil \
9192
python-stdlib/tempfile \
9293
python-stdlib/time \
94+
python-stdlib/unittest/tests \
9395
python-stdlib/unittest-discover/tests \
9496
; do
9597
(cd $path && $MICROPYTHON -m unittest)

0 commit comments

Comments
 (0)