python-urlopen 0.1.4__tar.gz → 0.1.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-urlopen
3
- Version: 0.1.4
3
+ Version: 0.1.5
4
4
  Summary: Python urlopen wrapper.
5
5
  Home-page: https://github.com/ChenyangGao/python-modules/tree/main/python-urlopen
6
6
  License: MIT
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "python-urlopen"
3
- version = "0.1.4"
3
+ version = "0.1.5"
4
4
  description = "Python urlopen wrapper."
5
5
  authors = ["ChenyangGao <wosiwujm@gmail.com>"]
6
6
  license = "MIT"
@@ -2,7 +2,7 @@
2
2
  # coding: utf-8
3
3
 
4
4
  __author__ = "ChenyangGao <https://chenyanggao.github.io>"
5
- __version__ = (0, 1, 4)
5
+ __version__ = (0, 1, 5)
6
6
  __all__ = ["urlopen", "request", "download"]
7
7
 
8
8
  from collections import defaultdict, deque, UserString
@@ -273,19 +273,28 @@ def urlopen(
273
273
  request = url
274
274
  else:
275
275
  if isinstance(data, PathLike):
276
- data = bio_chunk_iter(open(data, "rb"))
277
- elif isinstance(data, SupportsRead):
278
- data = bio_chunk_iter(data)
279
- request = Request(**normalize_request_args( # type: ignore
280
- method=method,
281
- url=url,
282
- params=params,
283
- data=data,
284
- json=json,
285
- files=files,
286
- headers=headers,
287
- ensure_ascii=True,
288
- ))
276
+ data = open(data, "rb")
277
+ if isinstance(data, SupportsRead):
278
+ request_args = normalize_request_args(
279
+ method=method,
280
+ url=url,
281
+ params=params,
282
+ headers=headers,
283
+ ensure_ascii=True,
284
+ )
285
+ request_args["data"] = data # type: ignore
286
+ else:
287
+ request_args = normalize_request_args(
288
+ method=method,
289
+ url=url,
290
+ params=params,
291
+ data=data,
292
+ json=json,
293
+ files=files,
294
+ headers=headers,
295
+ ensure_ascii=True,
296
+ )
297
+ request = Request(**request_args) # type: ignore
289
298
  if proxies:
290
299
  for host, type in iter_items(proxies):
291
300
  request.set_proxy(host, type)
File without changes
File without changes