Skip to content

Conversation

@HyeockJinKim
Copy link
Contributor

Generate TypeError when index return non-integer value

Fixes#96

@codecov-io
Copy link

codecov-io commented Sep 28, 2019

Codecov Report

Merging #97 into master will increase coverage by 0.26%.
The diff coverage is 85.71%.

Impacted file tree graph

@@ Coverage Diff @@## master #97 +/- ## ========================================== + Coverage 69.64% 69.91% +0.26%  ========================================== Files 60 60 Lines 10810 10817 +7 ========================================== + Hits 7529 7563 +34 + Misses 2750 2729 -21 + Partials 531 525 -6
Impacted FilesCoverage Δ
py/internal.go44.13% <100%> (+2.34%)⬆️
py/range.go86.66% <84.61%> (-0.68%)⬇️
py/slice.go84% <0%> (+2%)⬆️
py/list.go50.36% <0%> (+3.64%)⬆️
py/tuple.go50.92% <0%> (+11.11%)⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update af17d7d...313242b. Read the comment docs.

@HyeockJinKim
Copy link
ContributorAuthor

@corona10
Can I get a review?

@ghost
Copy link

Does this also affect the list type?
CPython supports:

>>>l= [1,2] >>>classC: ... def__index__(self): ... return1 ... >>>l[C()] 2

If your change has an influence on this, you could add a test for list, too.

Generate TypeError when __index__ return non-integer value Fixesgo-python#96
When an error occurs, the error is returned and when the value is none the slice's values have a default value.
Add tests for __index__ in list, tuple, string
@HyeockJinKim
Copy link
ContributorAuthor

@Tim-St
This fix affects strings, tuples, and lists.
So I added test code for each one. Would you like to review it again?

@ghost
Copy link

@HyeockJinKim Looks good, I think it should work now!

@ncwncw merged commit 36da816 into go-python:masterOct 1, 2019
@ncw
Copy link
Collaborator

ncw commented Oct 1, 2019

That looks great now - thank you :-)

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Handle the return of non-integer value in __index__ function

3 participants

@HyeockJinKim@codecov-io@ncw