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

Comment not parsed #95

Closed
Marrin opened this issue Mar 30, 2016 · 7 comments
Closed

Comment not parsed #95

Marrin opened this issue Mar 30, 2016 · 7 comments
Labels

Comments

@Marrin
Copy link

Marrin commented Mar 30, 2016

Maybe this is connected to issue #67 but it's worse than just having the wrong node type, because it breaks the round trip promise:

In [27]: source = '''#!/usr/bin/env python
# coding: utf8
'''

In [28]: red = RedBaron(source)

In [29]: red
Out[29]: 
0   '#!/usr/bin/env python\n'
1   '#!/usr/bin/env python\n'


In [30]: red[0]
Out[30]: '#!/usr/bin/env python\n'

In [31]: red[1]
Out[31]: '#!/usr/bin/env python\n'

In [32]: red.dumps()
Out[32]: '#!/usr/bin/env python\n\n'

The second node seemingly repeats the first comment but when rendered back to source even that is gone, as is the coding comment. Tested with Python 2.7, baron 0.6.2, and redbaron 0.6.1

@ibizaman
Copy link
Collaborator

Yes, comment handling is pretty brittle at the moment. Thanks for reporting!

@gtors
Copy link
Contributor

gtors commented Aug 30, 2016

It's bug of IPython shell: proof
In native python shell the bug is not reproduced.

@b5y
Copy link
Contributor

b5y commented Aug 30, 2016

@gtors Interesting. I know that IPython have some bugs. One of them with StringIO I detected few months ago (it was not new version of IPython, but it does not matter).

I have used python 2.7 and RedBaron had bug with comments. Did you try with Python 2.7?

@gtors
Copy link
Contributor

gtors commented Aug 30, 2016

@b5y Python 2.7 shell also works fine: asciinema
p.s.: for py3 I use patched version of baron, so, result of calling parse in py2 is a bit different.

@ibizaman
Copy link
Collaborator

I can unfortunately confirm it's an iPython problem:
img-2016-12-21-230631
img-2016-12-21-230615

@gtors do you have an idea of what the problem is?
@b5y @Marrin latest baron has (one of) the comment issue fixed, see PyCQA/baron#88

@gtors
Copy link
Contributor

gtors commented Dec 22, 2016

@ibizaman ipython/ipython#9919

@Marrin
Copy link
Author

Marrin commented Jun 11, 2023

I've revisited this with current versions of IPython and the involved libraries and the problem is fixed/gone. Given that it was a bug in IPythone anyway, I think this should be closed.

@Marrin Marrin closed this as completed Jun 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants