Giter Site home page Giter Site logo

Comments (4)

allenluce avatar allenluce commented on May 18, 2024

I'd think this is OK to leave as it is. A write to a non-binary filehandle in Python 3 results in an error:

Python 3.5.0 (default, Sep 23 2015, 04:42:00)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.72)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> byte_fractions = b'\xe2\x85\x93 \xe2\x85\x94 \xe2\x85\x95 \xe2\x85\x96'
>>> with open("/tmp/foo", 'w') as f:
...   f.write(byte_fractions)
...
Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
TypeError: write() argument must be str, not bytes
>>>

from pyfakefs.

jmcgeheeiv avatar jmcgeheeiv commented on May 18, 2024

Thank you for lending your expertise with binary files.

Indeed the test as it is now does not work with binary data in Python3. I was thinking that the test should be updated to write the file in mode 'wb' and read it in mode 'rb'.

When you do this, pyfakefs raises an exception, complaining that the data cannot be encoded as ascii. This is a bug in pyfakefs.

So I think that the solution it to change the modes in the test to 'wb' and 'rb', and then fixing pyfakes so that the test passes.

from pyfakefs.

dougluce avatar dougluce commented on May 18, 2024

OK, I see what you mean now. The changes I made in #60 should take care of the pyfakefs problem. I've just added the test case you suggested and another one to test Py3-specific behavior with writing in binary and reading in non-binary.

from pyfakefs.

jmcgeheeiv avatar jmcgeheeiv commented on May 18, 2024

Tests pass. Good thing I left it to the expert!

from pyfakefs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.