workers-runtime-sdk 1.4.0__tar.gz → 1.4.1__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.
Files changed (17) hide show
  1. {workers_runtime_sdk-1.4.0 → workers_runtime_sdk-1.4.1}/CHANGELOG.md +9 -0
  2. {workers_runtime_sdk-1.4.0 → workers_runtime_sdk-1.4.1}/PKG-INFO +1 -1
  3. {workers_runtime_sdk-1.4.0 → workers_runtime_sdk-1.4.1}/pyproject.toml +1 -1
  4. {workers_runtime_sdk-1.4.0 → workers_runtime_sdk-1.4.1}/src/workers/_workers.py +33 -12
  5. {workers_runtime_sdk-1.4.0 → workers_runtime_sdk-1.4.1}/.gitignore +0 -0
  6. {workers_runtime_sdk-1.4.0 → workers_runtime_sdk-1.4.1}/AGENTS.md +0 -0
  7. {workers_runtime_sdk-1.4.0 → workers_runtime_sdk-1.4.1}/README.md +0 -0
  8. {workers_runtime_sdk-1.4.0 → workers_runtime_sdk-1.4.1}/src/_cloudflare_compat_flags.pyi +0 -0
  9. {workers_runtime_sdk-1.4.0 → workers_runtime_sdk-1.4.1}/src/_pyodide_entrypoint_helper.pyi +0 -0
  10. {workers_runtime_sdk-1.4.0 → workers_runtime_sdk-1.4.1}/src/_workers_sdk_entropy_import_context.pth +0 -0
  11. {workers_runtime_sdk-1.4.0 → workers_runtime_sdk-1.4.1}/src/_workers_sdk_entropy_import_context.py +0 -0
  12. {workers_runtime_sdk-1.4.0 → workers_runtime_sdk-1.4.1}/src/_workers_sdk_entropy_import_context_loader.py +0 -0
  13. {workers_runtime_sdk-1.4.0 → workers_runtime_sdk-1.4.1}/src/asgi.py +0 -0
  14. {workers_runtime_sdk-1.4.0 → workers_runtime_sdk-1.4.1}/src/workers/__init__.py +0 -0
  15. {workers_runtime_sdk-1.4.0 → workers_runtime_sdk-1.4.1}/src/workers/py.typed +0 -0
  16. {workers_runtime_sdk-1.4.0 → workers_runtime_sdk-1.4.1}/src/workers/workflows.py +0 -0
  17. {workers_runtime_sdk-1.4.0 → workers_runtime_sdk-1.4.1}/uv.lock +0 -0
@@ -2,6 +2,15 @@
2
2
 
3
3
  <!-- version list -->
4
4
 
5
+ ## v1.4.1 (2026-06-18)
6
+
7
+ ### Bug Fixes
8
+
9
+ - Fix ReadableStream being incorrectly wrapped by BindingWrapper
10
+ ([#128](https://github.com/cloudflare/workers-py/pull/128),
11
+ [`85ad1f3`](https://github.com/cloudflare/workers-py/commit/85ad1f33d5f23fd932c0eac5cc5a9f7d39159423))
12
+
13
+
5
14
  ## v1.4.0 (2026-06-17)
6
15
 
7
16
  ### Features
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: workers-runtime-sdk
3
- Version: 1.4.0
3
+ Version: 1.4.1
4
4
  Summary: Python SDK for Cloudflare Workers
5
5
  Project-URL: Homepage, https://github.com/cloudflare/workers-py
6
6
  Project-URL: Bug Tracker, https://github.com/cloudflare/workers-py/issues
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "workers-runtime-sdk"
7
- version = "1.4.0"
7
+ version = "1.4.1"
8
8
  description = "Python SDK for Cloudflare Workers"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.12"
@@ -392,6 +392,19 @@ RESPONSE_ACCEPTED_TYPES = {
392
392
  "Response",
393
393
  }
394
394
 
395
+ # JS built-in types that should NOT be wrapped in _BindingWrapper.
396
+ # These have their own Python-side semantics (e.g. passed directly to Response())
397
+ # and wrapping them breaks property access like `.constructor.name`.
398
+ _JS_PASSTHROUGH_TYPES = RESPONSE_ACCEPTED_TYPES | {
399
+ "Headers",
400
+ }
401
+
402
+
403
+ def _get_js_constructor_name(obj) -> str | None:
404
+ if hasattr(obj, "constructor"):
405
+ return obj.constructor.name
406
+ return None
407
+
395
408
 
396
409
  class Response(FetchResponse):
397
410
  """
@@ -414,11 +427,10 @@ class Response(FetchResponse):
414
427
  https://developer.mozilla.org/en-US/docs/Web/API/Response/Response.
415
428
  """
416
429
  # Verify passed in types.
417
- if hasattr(body, "constructor"):
418
- if body.constructor.name not in RESPONSE_ACCEPTED_TYPES:
419
- raise TypeError(
420
- f"Unsupported type in Response: {body.constructor.name}"
421
- )
430
+ js_type = _get_js_constructor_name(body)
431
+ if js_type:
432
+ if js_type not in RESPONSE_ACCEPTED_TYPES:
433
+ raise TypeError(f"Unsupported type in Response: {js_type}")
422
434
  elif not isinstance(body, str | FormData | bytes) and body is not None:
423
435
  raise TypeError(f"Unsupported type in Response: {type(body).__name__}")
424
436
 
@@ -1110,20 +1122,29 @@ class _BindingWrapper:
1110
1122
  def __init__(self, binding):
1111
1123
  self._binding = binding
1112
1124
 
1125
+ def _should_wrap_nested_attribute(self, jsobj) -> bool:
1126
+ if not isinstance(jsobj, JsProxy):
1127
+ return False
1128
+
1129
+ # TODO: This allowlist approach is a workaround. The long-term fix is to
1130
+ # add dedicated Python wrappers for these types in python_from_rpc so they
1131
+ # never reach _BindingWrapper in the first place.
1132
+ js_type = _get_js_constructor_name(jsobj)
1133
+ return js_type and js_type not in _JS_PASSTHROUGH_TYPES
1134
+
1113
1135
  def _convert_result(self, result):
1114
1136
  converted = python_from_rpc(result)
1115
1137
 
1116
1138
  # After python_from_rpc, some objects may still be JsProxy objects.
1117
- # For now, we wrap all of them with the _BindingWrapper (or a subclass of it)
1118
- # so that accessing attributes on them will be properly converted.
1119
-
1120
- # TODO: This is a bit of a hack. We should revisit when there are more
1121
- # bindings to support with different return types.
1122
- if isinstance(converted, JsProxy):
1139
+ # We need to wrap them with _BindingWrapper (or a subclass of it) again
1140
+ # to ensure that accessing attributes on them will be properly converted.
1141
+ if self._should_wrap_nested_attribute(converted):
1123
1142
  return self.__class__(converted)
1124
1143
  if isinstance(converted, list):
1125
1144
  return [
1126
- self.__class__(item) if isinstance(item, JsProxy) else item
1145
+ self.__class__(item)
1146
+ if self._should_wrap_nested_attribute(item)
1147
+ else item
1127
1148
  for item in converted
1128
1149
  ]
1129
1150
  return converted