Closed esupoff closed 5 years ago
Hmm... capturing a PyCharm debugging session would be a bit tedious... I hope a simpler example would suffice:
$ pip3.7 install astor
Collecting astor
Using cached https://files.pythonhosted.org/packages/35/6b/11530768cac581a12952a2aad00e1526b89d242d0b9f59534ef6e6a1752f/astor-0.7.1-py2.py3-none-any.whl
Installing collected packages: astor
Successfully installed astor-0.7.1
$ python3.7
Python 3.7.2 (default, Feb 13 2019, 02:55:09)
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import astor
>>> x = astor.TreeWalk()
>>> x.__dict__
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: descriptor '__dict__' for 'MetaFlatten' objects doesn't apply to 'TreeWalk' object
$ pip3.7 install --upgrade git+https://github.com/esupoff/astor.git@0.7.1-z
Collecting git+https://github.com/esupoff/astor.git@0.7.1-z
Cloning https://github.com/esupoff/astor.git (to revision 0.7.1-z) to /tmp/pip-req-build-by761dee
Running command git clone -q https://github.com/esupoff/astor.git /tmp/pip-req-build-by761dee
Installing collected packages: astor
Found existing installation: astor 0.7.1
Uninstalling astor-0.7.1:
Successfully uninstalled astor-0.7.1
Running setup.py install for astor ... done
Successfully installed astor-0.7.1
$ python3.7
python3.7
Python 3.7.2 (default, Feb 13 2019, 02:55:09)
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import astor
>>> x = astor.TreeWalk()
>>> x.__dict__
{'nodestack': [], 'pre_handlers': {}, 'post_handlers': {}}
Also, without this patch in IPython you couldn't do this:
Python 3.7.2 (default, Feb 13 2019, 02:55:09)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.2.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import astor
In [2]: x = astor.TreeWalk()
In [3]: x. # <- hit Tab here
nodestack parent_name pre_handlers setup()
parent post_handlers replace() walk()
Thank you!
Fixes https://github.com/berkerpeksag/astor/issues/136