The Wayback Machine - https://web.archive.org/web/20251231214002/https://github.com/python/cpython/pull/109642
Skip to content

Conversation

@skirpichev
Copy link
Contributor

@skirpichev skirpichev commented Sep 21, 2023 •

  • c_powu: L189 (c_powu() called with n < 100 and mask can't overflow)
  • complex_hash: L459, L462 (in current implementation of hashing, -1 is reserved)
  • complex_richcompare: L643, L669 (TO_COMPLEX calls are redundant)
  • complex_subtype_from_string: L892 (complex_subtype_from_string() helper called only on L949 with unicode object at v)
  • actual_complex_new: L960 (PyComplex_Check can't be true here), L960 (test added)
  • complex_new_impl: L1028 (test added)
  • complex_new_impl: L1034 (here r is not a complex subtype, hence above try_complex_special_method() call was unsuccessful)
  • complex_new_impl: L1068 (here r is a complex subtype, hence own_r==1)
  • complex_from_number: L1150 (test added)

Line numbers are wrt to complexobject.c at 8a284e189673582e2.


Everything (except for memory errors) should be covered by tests in test_complex.py and test_capi/test_complex.py.

@skirpichev skirpichev changed the title Increase test coverage for complexobject.c Sep 24, 2023
skirpichev added a commit to skirpichev/cpython that referenced this pull request Sep 27, 2023
skirpichev added a commit to skirpichev/cpython that referenced this pull request Sep 27, 2023
Copy link
Contributor

@eendebakpt eendebakpt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR increases test coverage in two ways:: adding tests and removing some code paths that cannot be reached. The added tests are quite safe to add. The changes to the C code are a bit hard to comprehend, but I checked them and seem valid to me. Also they are guarded by asserts.

Only one comment on a docstring, but otherwise looks good.

Co-authored-by: Pieter Eendebak <pieter.eendebak@gmail.com>
@skirpichev skirpichev marked this pull request as ready for review May 31, 2024 10:12
@mdickinson
Copy link
Member

Please could one of the core developers watching this PR remove the request for my review? Thank you!

@serhiy-storchaka serhiy-storchaka removed the request for review from mdickinson August 13, 2024 17:14
@skirpichev skirpichev requested a review from picnixz October 6, 2024 03:48
@skirpichev
Copy link
Contributor Author

@picnixz, this is quite old PR with a bunch of nitpicks. I would appreciate if you take a look.

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
@skirpichev skirpichev requested a review from picnixz October 6, 2024 10:38
Copy link
Member

@picnixz picnixz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final nitpicks that I missed. Otherwise I think it's ok? (I'm not familiar enough with this part of the code but it looks good to me).

@skirpichev skirpichev requested a review from picnixz October 7, 2024 01:52
Copy link
Member

@picnixz picnixz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a question otherwise LGTM.

@Coffigny94

This comment was marked as off-topic.

@skirpichev
Copy link
Contributor Author

@serhiy-storchaka, I suspect that @mdickinson was -1 on this pr; thus, it should be closed together with the issue.

Let me know if it this make sense for you in some form at least partially (e.g. removing useless TO_COMPLEX or useless PyUnicode_Check()). If so, I'll quickly revert the rest.

@serhiy-storchaka
Copy link
Member

If @mdickinson was -1, I am -1 too. This issue already taken up too much of your and my time. Too much for any potential benefits.

@skirpichev skirpichev closed this Oct 14, 2024
@skirpichev skirpichev deleted the complex-cov branch October 14, 2024 16:51
@skirpichev
Copy link
Contributor Author

If @mdickinson was -1

That's only my guess.

Anyway, thank you for your time. @picnixz and @eendebakpt, thank for reviews.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment