Skip to content

gh-109802: removed inaccessible code from complexobject.c - #109642

Closed
skirpichev wants to merge 56 commits into
python:mainfrom
skirpichev:complex-cov
Closed

gh-109802: removed inaccessible code from complexobject.c#109642
skirpichev wants to merge 56 commits into
python:mainfrom
skirpichev:complex-cov

Conversation

@skirpichev

@skirpichevskirpichev commented Sep 21, 2023

Copy link
Copy Markdown
Member
  • 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.

@skirpichevskirpichev changed the title Increase test coverage for complexobject.cgh-109802: Increase test coverage for complexobject.cSep 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
Comment threadObjects/complexobject.c Outdated
Comment threadObjects/complexobject.c Outdated

@eendebakpteendebakpt left a comment

Copy link
Copy Markdown
Contributor

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.

Comment threadObjects/complexobject.c Outdated
Comment threadObjects/complexobject.c
Comment threadObjects/complexobject.c
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
Copy Markdown
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 mdickinsonAugust 13, 2024 17:14
@skirpichev

Copy link
Copy Markdown
MemberAuthor

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

Comment threadObjects/complexobject.c Outdated
Comment threadObjects/complexobject.c Outdated
Comment threadObjects/complexobject.c Outdated
Comment threadObjects/complexobject.c Outdated
Comment threadObjects/complexobject.c
Comment threadObjects/complexobject.c
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Comment threadObjects/complexobject.c Outdated

@picnixzpicnixz left a comment

Copy link
Copy Markdown
Member

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).

Comment threadObjects/complexobject.c Outdated
Comment threadObjects/complexobject.c
Comment threadObjects/complexobject.c Outdated

@picnixzpicnixz left a comment

Copy link
Copy Markdown
Member

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.

Comment threadObjects/complexobject.c
@Coffigny94

This comment was marked as off-topic.

@skirpichev

Copy link
Copy Markdown
MemberAuthor

@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
Copy Markdown
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 deleted the complex-cov branch October 14, 2024 16:51
@skirpichev

Copy link
Copy Markdown
MemberAuthor

If @mdickinson was -1

That's only my guess.

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

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants

@skirpichev@serhiy-storchaka@mdickinson@Coffigny94@eendebakpt@picnixz@AlexWaygood