On Sat, Feb 01, 2020 at 01:52:38AM +0200, Alex Hall wrote:

> Here's a simple runtime implementation that doesn't require any
> dependencies or source code access:
> 
> import dis

So this is not likely to ever work in IronPython or Jython.

There are no stability guarantees about the byte-code generated by 
CPython, so you may be chasing a moving target here.

You ought to test your code before posting, because I've tried it in 
3.5, 3.7 and 3.8 and I get the same error each time:

    TypeError: Expected maxsize to be an integer or None

which is a simple error in the call to the lru_cache decorator. After 
fixing that, I tried it again in 3.7 and I get this:

    >>> x = 1
    >>> nameof.nameof(x)
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/home/srv-steve/python/nameof.py", line 7, in nameof
        return _nameof(frame.f_code, frame.f_lasti)
      File "/home/srv-steve/python/nameof.py", line 17, in _nameof
        assert current_instruction.opname == "CALL_FUNCTION"
    AssertionError


-- 
Steven
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/25TBO3VYZIVMAN36K5NTNRZ5VUGVIBCD/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to