Skip to content

Handle the non-integer return of __index__ - #97

Merged
ncw merged 4 commits into
go-python:masterfrom
HyeockJinKim:issue96
Oct 1, 2019
Merged

Handle the non-integer return of __index__#97
ncw merged 4 commits into
go-python:masterfrom
HyeockJinKim:issue96

Conversation

@HyeockJinKim

Copy link
Copy Markdown
Contributor

Generate TypeError when index return non-integer value

Fixes #96

@codecov-io

codecov-io commented Sep 28, 2019

Copy link
Copy Markdown

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
Copy Markdown
Contributor Author

@corona10
Can I get a review?

@corona10
corona10 requested review from corona10 and ncw September 29, 2019 08:34
@ghost

ghost commented Sep 29, 2019

Copy link
Copy Markdown

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
Copy Markdown
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

ghost commented Sep 29, 2019

Copy link
Copy Markdown

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

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

ncw commented Oct 1, 2019

Copy link
Copy Markdown
Collaborator

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

3 participants