clarete/forbiddenfruit

curse error

Cologler opened this issue · 3 comments

import forbiddenfruit

forbiddenfruit.curse(str, 'first', lambda x: x[0])
'123'.first() # '1'

is Okay. But if you try:

import forbiddenfruit

hasattr(str, 'first')
forbiddenfruit.curse(str, 'first', lambda x: x[0])
'123'.first() # raise AttributeError

Any patch for this?

fixes by insert a line:

import forbiddenfruit
import ctypes

hasattr(str, 'first')
forbiddenfruit.curse(str, 'first', lambda x: x[0])
ctypes.pythonapi.PyType_Modified(ctypes.py_object(str))
'123'.first()

That's such an interesting bug. I'll take a look! Thanks for mentioning the workaround! <o/

I just make a PR (base on your pyenv-versions) and all tests pass.