Skip to content

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

Closed

Description

@ikanobori

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'

Activity

  1. ikanobori commented on Jul 4, 2014

    @ikanobori
    ContributorAuthor
  2. ikanobori commented on Jul 4, 2014

    @ikanobori
    ContributorAuthor

    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

  3. ikanobori commented on Jul 4, 2014

    @ikanobori
    ContributorAuthor

    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:

  4. ikanobori commented on Jul 4, 2014

    @ikanobori
    ContributorAuthor

    @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:

  5. ikanobori commented on Jul 4, 2014

    @ikanobori
    ContributorAuthor

    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:

  6. ikanobori commented on Jul 4, 2014

    @ikanobori
    ContributorAuthor

    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

  7. added a commit that references this issue on Jul 5, 2014
    9d425fc
  8. myint commented on Jul 5, 2014

    @myint
    Contributor

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

  9. thomasballinger commented on Jul 5, 2014

    @thomasballinger
    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.

  10. added a commit that references this issue on Jul 6, 2014
    5b3a7c0
  11. added a commit that references this issue on Jul 19, 2014
    4a65c7b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions