-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
print() builtin uses printf() instead of sys.stdout #209
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
Comments
Agree. There needs to be a way of doing this in a portable way (that works on unix and stm, for example). That means stm needs to define a sys.stdout object. Probably the best thing to do is provide file descriptors in the stm port with 0,1,2 mapping to std in,out,err as usual. Then the same file code (currently in unix/) can be used. |
From Python perspective, no need to use to mimic it down to numbers. Just an object which implements read/write C-level protocol, it can wrap FIL* or some serial object just as well.
|
All in all, there's known workaround - just don't mix print() and sys.write(), and good fix will require some thinking (one thought is that ->print() should be provided with both stream interface for efficient out, and printf interface for convenience). So, this is more of "known issue", not something to work on right away (IMHO). |
Resolved. |
Python defines print() in terms of using sys.stdout python object for output (http://docs.python.org/3.3/library/functions.html#print) uPy currently uses libc function printf(). This may lead to different buffering and garbled output.
The text was updated successfully, but these errors were encountered: