python - Is Filestorage storage.read() open the file in binary mode? -


i have looked source , documentation of werkzeug, it's specified mode it's opened. since default open mode normal file text mode, brings me question. earlier, had problem save data=storage.read() largebinary type in sqlalchemy, error saying: can't convert unicode byte type.

yes, files opened in binary mode. see default_stream_factory() function source:

def default_stream_factory(total_content_length, filename, content_type,                            content_length=none):     """the stream factory used per default."""     if total_content_length > 1024 * 500:         return temporaryfile('wb+')     return bytesio() 

so either temporaryfile() object opened in wb+ mode (write , read, binary), or in-memory bytesio object.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -