@@ -149,16 +149,24 @@ impl PyStepParameterSpaceIterator {
149149 fn new (
150150 step : Option < & PyStep > ,
151151 space : Option < & PyStepParameterSpace > ,
152- chunks_task_count_override : Option < usize > ,
152+ chunks_task_count_override : Option < i64 > ,
153153 ) -> PyResult < Self > {
154- // Rejected rather than clamped: openjd-model applies `.max(1)` to the
155- // override, so 0 would silently mean 1. The `chunks_default_task_count`
156- // setter already refuses 0, and the two should not disagree.
157- if chunks_task_count_override == Some ( 0 ) {
158- return Err ( pyo3:: exceptions:: PyValueError :: new_err (
159- "chunks_task_count_override must be a positive integer." ,
160- ) ) ;
161- }
154+ // Taken as i64, not usize, so a negative value reaches this check instead of
155+ // failing pyo3's unsigned extraction with OverflowError. Every non-positive
156+ // value should report the same ValueError the message and the spec promise.
157+ //
158+ // Rejected rather than clamped: openjd-model applies `.max(1)` to the override,
159+ // so 0 would silently mean 1. The `chunks_default_task_count` setter already
160+ // refuses 0, and the two should not disagree.
161+ let chunks_task_count_override: Option < usize > = match chunks_task_count_override {
162+ Some ( n) if n <= 0 => {
163+ return Err ( pyo3:: exceptions:: PyValueError :: new_err (
164+ "chunks_task_count_override must be a positive integer." ,
165+ ) ) ;
166+ }
167+ Some ( n) => Some ( n as usize ) ,
168+ None => None ,
169+ } ;
162170 let ps = if let Some ( s) = space {
163171 s. inner . clone ( )
164172 } else if let Some ( st) = step {
0 commit comments