Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle the non-integer return of __index__ #97

Merged
merged 4 commits into from
Oct 1, 2019

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 Files Coverage Δ
py/internal.go 44.13% <100%> (+2.34%) ⬆️
py/range.go 86.66% <84.61%> (-0.68%) ⬇️
py/slice.go 84% <0%> (+2%) ⬆️
py/list.go 50.36% <0%> (+3.64%) ⬆️
py/tuple.go 50.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
Contributor Author

@corona10
Can I get a review?

@ghost
Copy link

ghost commented Sep 29, 2019

Does this also affect the list type?
CPython supports:

>>> l = [1,2]
>>> class C:
...   def __index__(self):
...     return 1
...
>>> 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

Fixes go-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
Contributor Author

@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

ghost commented Sep 29, 2019

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

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

ncw commented Oct 1, 2019

That looks great now - thank you :-)

Sign up for free to 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