18 Commits

Author SHA1 Message Date
Md Kaif
7fd7e2db15
fix(float): abs(-0.0) should return 0.0 (#534)
abs(-0.0) returns -0.0 instead of 0.0, and math.fabs(-0.0) does the
same. Both come from the idiom (x < 0) ? -x : x. Since -0.0 < 0 is
false, the negative zero is returned unchanged.

The idiom appears twice, once in dmath_fabs and once open-coded in
float__abs__. Fix dmath_fabs by clearing the sign bit, the same way
dmath_copysign just above it works, and make float__abs__ call the
shared helper instead of repeating the comparison.

abs(-0.0) == 0.0 is true even with the bug, because -0.0 == 0.0 under
IEEE 754, so the added tests compare str(...) to check the sign.
2026-07-21 19:36:08 +08:00
Md Kaif
005550e92a
fix(str): zfill should preserve a leading sign (#533)
zfill writes the padding zeros before the whole string, so a leading
+ or - ends up in the middle of the result instead of staying in front.
For example "-5".zfill(4) gave '00-5' where CPython gives '-005'.

CPython inserts the padding after the sign character, and the sign
counts toward the requested width. Write the sign first, then the
zeros, then the rest of the string. delta is still computed before
this, so the total length is unchanged.

The existing tests only covered unsigned strings, which is why this
went unnoticed. Added three asserts alongside them.
2026-07-21 19:09:11 +08:00
thermalPasteMilkshake
e144785436
re-checking (#531) 2026-07-11 10:25:27 +08:00
blueloveTH
27fde79de6 Update py_object.c 2026-07-09 12:46:04 +08:00
blueloveTH
21ff0751dc fix error name 2026-07-06 17:42:01 +08:00
Rob McMullen
664ce091f8
Added str.splitlines (#523)
* uses same algorithm as CPython, supports all CPython eol characters
  in https://docs.python.org/3/library/stdtypes.html#str.splitlines
2026-06-28 21:56:47 +08:00
blueloveTH
94e71d8581 expose divmod 2026-06-24 16:38:18 +08:00
blueloveTH
8c4ed3bc34 fix a bug of str 2026-06-02 20:42:03 +08:00
blueloveTH
c39d86e999 add __mod__ 2026-04-29 12:54:04 +08:00
blueloveTH
35917fc5f4 fix #468 2026-03-04 14:30:35 +08:00
blueloveTH
aaf611eff3 up 2026-02-21 21:08:33 +08:00
blueloveTH
48b70c944e fix #426 2026-01-26 17:50:03 +08:00
blueloveTH
9ef38d605b fix bool-int ops 2026-01-14 16:14:08 +08:00
blueloveTH
0251f924c3 fix leak and improve pickle 2025-10-08 21:09:14 +08:00
blueloveTH
c30a7adaff add cpy11__float_div_mod 2025-09-29 11:24:41 +08:00
blueloveTH
354e8fc03f support divmod for pos float 2025-09-28 19:31:47 +08:00
blueloveTH
62491dd99a reimpl str.format 2025-09-17 14:10:26 +08:00
blueloveTH
d3d61dde0c refactor code 2025-09-08 15:41:44 +08:00