flpit 0.4.0.dev1__tar.gz → 0.4.0.dev3__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.5
2
2
  Name: flpit
3
- Version: 0.4.0.dev1
3
+ Version: 0.4.0.dev3
4
4
  Summary: Fluent LINQ for Python — flip your iterables
5
5
  Project-URL: Homepage, https://github.com/riemar/flpit
6
6
  Project-URL: Repository, https://github.com/riemar/flpit
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "flpit"
3
- version = "0.4.0.dev1"
3
+ version = "0.4.0.dev3"
4
4
  description = "Fluent LINQ for Python — flip your iterables"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.12"
@@ -290,8 +290,9 @@ def dotnet_context() -> AbstractContextManager[decimal.Context]:
290
290
  # 1. Create and configure pure Context object
291
291
  ctx = decimal.getcontext().copy()
292
292
  ctx.prec = max(ctx.prec, 29)
293
+ ctx.Emax = ctx.prec - 1
293
294
  ctx.traps[Overflow] = True
294
- ctx.traps[Inexact] = True
295
+ ctx.traps[Inexact] = False
295
296
 
296
297
  return decimal.localcontext(ctx)
297
298
 
@@ -1314,12 +1315,17 @@ class FlpIt[TItem](Iterable[TItem]):
1314
1315
  else:
1315
1316
  try:
1316
1317
  total += item
1317
- except (Overflow, Inexact):
1318
+ except Overflow:
1318
1319
  raise OverflowError(
1319
1320
  "System.OverflowException: Value was either too large or too small for a Decimal."
1320
1321
  )
1321
1322
  count += 1
1322
1323
 
1324
+ if isinstance(total, Decimal) and total.adjusted() >= decimal.getcontext().prec:
1325
+ raise OverflowError(
1326
+ "System.OverflowException: Value was either too large or too small for a Decimal."
1327
+ )
1328
+
1323
1329
  return total, count
1324
1330
 
1325
1331
 
@@ -59,6 +59,7 @@ import socket
59
59
  import threading
60
60
  import time
61
61
  import warnings
62
+ import weakref
62
63
  from collections import deque
63
64
  from collections.abc import AsyncGenerator, Generator
64
65
  from dataclasses import dataclass
@@ -2411,9 +2412,15 @@ class _Runtime:
2411
2412
  def __init__(self, *, min_workers: int, max_workers: int) -> None:
2412
2413
  self._pool = _WorkerPool(self, min_workers, max_workers)
2413
2414
  self._io = _IOReactor(self)
2414
- # Pending tasks, so shutdown can cancel them. add()/discard() are
2415
- # single atomic operations with the GIL and on free-threaded builds.
2416
- self._tasks: set[Task[Any]] = set()
2415
+ # Pending tasks, so shutdown can cancel them. The registry is weak on
2416
+ # purpose: a pending task that nothing references can never make
2417
+ # progress (anything that can resume it -- the pool queue, a running
2418
+ # worker, the timer, the selector, a continuation list -- holds it
2419
+ # strongly), so it is garbage, exactly like an abandoned
2420
+ # TaskCompletionSource in .NET. A strong registry would keep every
2421
+ # such task, and the coroutine parked on it, alive for the life of
2422
+ # the process.
2423
+ self._tasks: weakref.WeakSet[Task[Any]] = weakref.WeakSet()
2417
2424
  self._state_lock = threading.Lock()
2418
2425
  self._shutdown_lock = threading.Lock()
2419
2426
  self._shutdown_requested = False
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes