Skip to content

AttributeError: 'FakeStdin' object has no attribute 'encoding' #293

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

Closed
ikanobori opened this issue Jul 4, 2014 · 8 comments
Closed

AttributeError: 'FakeStdin' object has no attribute 'encoding' #293

ikanobori opened this issue Jul 4, 2014 · 8 comments
Labels

Comments

@ikanobori
Copy link
Contributor

bpython:

>>> import sys
>>> sys.stdin.encoding
Traceback (most recent call last):
  File "<input>", line 1, in <module>
AttributeError: 'FakeStdin' object has no attribute 'encoding'

python proper:

>>> import sys
>>> sys.stdin.encoding
'UTF-8'

@ikanobori
Copy link
Contributor Author

Fix in https://bitbucket.org/bobf/bpython/pull-request/58/fix-293/diff


Original Comment By:

@ikanobori
Copy link
Contributor Author

The only one I personally encountered was sys.stdin.encoding. I think it makes sense to hold off on the unused stuff. Thanks.


Original Comment By: Steven Myint

@ikanobori
Copy link
Contributor Author

So far I'm looking at adding:

from cli.FakeStdin

  • isatty (return True)
  • fileno (return 0)

from vanilla REPL:

  • close (sets closed)
  • closed (bool that does nothing)
  • encoding (hardcoded to "UTF8" for now)
  • name ('')
  • sys.stdin.newlines (None)
  • seek (nop)
  • tell (nop)
  • truncate (nop)
  • writelines (nop)
  • xreadlines (just alias to readlines for now)

However, it seems silly to write a bunch of code which may or may not do the right thing like this - I'd rather wait to hear that we need to implement something as a workaround. If our FakeStdin doesn't do something, it shouldn't implement it unless faking it makes things better for users. @myint, interested to hear what you and others think.

I don't know what to do with errors, but apparently need to find out.

I plan to add read later.


Original Comment By:

@ikanobori
Copy link
Contributor Author

@myint I'm looking at all of the attributes of sys.stdin in a vanilla repl and wondering if I should really implement all of them. Do you need this for something, or was this just prospective?


Original Comment By:

@ikanobori
Copy link
Contributor Author

Hm, we should probably add all of these then. Separate issue this example touches on: bpython-curtsies is currently hardcoded for utf-8. Is this a problem?


Original Comment By:

@ikanobori
Copy link
Contributor Author

This looks like a bug that is specific to bpython/curtsiesfrontend/repl.py. Note that curtsiesfrontend.repl.FakeStdin is missing various attributes (and functions) that exists in cli.FakeStdin.


Original Comment By: Steven Myint

@myint
Copy link
Contributor

myint commented Jul 5, 2014

So you guys are moving to GitHub? By the way, the comments look quite out of order. Compare this to the original.

@thomasballinger
Copy link
Member

Oof, you're right. @ikanobori think it's worth fixing? We don't have tons of long conversations that evolve over time, but it's always sad to lose history.

myint added a commit to myint/bpython that referenced this issue Feb 7, 2016
This is similar to bpython#293, which was fixed in a similar way. That case was for "sys.stdin".
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

3 participants