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

Cursing int __iter__ silently fails. #25

Open
0xf0f opened this issue Mar 28, 2019 · 2 comments
Open

Cursing int __iter__ silently fails. #25

0xf0f opened this issue Mar 28, 2019 · 2 comments

Comments

@0xf0f
Copy link

0xf0f commented Mar 28, 2019

>>> def int_iter(self):
	i = 0
	while i < self:
		yield i
		i += 1

		
>>> curse(int, '__iter__', int_iter)
>>> for i in 12:
	print('1231')

	
Traceback (most recent call last):
  File "<pyshell#19>", line 1, in <module>
    for i in 12:
TypeError: 'int' object is not iterable

Not sure if this is a bug or just unimplemented. Maybe raising a NotImplementedError exception would be helpful if it's the latter.

@clarete
Copy link
Owner

clarete commented Apr 19, 2019

Thanks for reporting! That's a good one! The handling of dunder methods was introduced quite recently (#24) and it didn't include the __iter__ protocol. Let me know if you have any interest in suggesting a fix, I can walk you through the code! I think that'd be the fastest way to get these changes in!

@alexchandel
Copy link

alexchandel commented Nov 19, 2019

@clarete Is anything required for implementing __repr__, __hash__, __call__, __iter__, __next__, or other missing dunder methods than adding them to PyTypeObject._fields_ and override_dict?

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

No branches or pull requests

3 participants