Add %q support.#793
Conversation
This allows us to use print("%q", some_qstr) instead
of print("%s", qstr_str(some_qstr))
|
This is useful, but might need some consideration and discussion:
|
Perhaps.
Personally, I think it is the way to go. The only reason we can't right now is that we use the native snprintf to print doubles:
The emergency exception buf code uses vsnprintf:
I could have factored it and renamed it to mp_snprintf, but objfloat calls snprintf and it needs to be the native one. |
|
For very constrained ports, it might be beneficial to be able use the system provided printf, so as not to duplicate this code by also having to include the uPy version. On the other hand, we pretty much need to include our own printf (or variant thereof) to produce Python compliant output when printing. It's pretty confusing at the moment what printf support exists, and what is needed, and what is used by who... |
|
IMHO, problem is dichotomic: "system" provided stuff can be more bloated, or can be broken (see #748). But if we do dynamic linking with decent libc, it makes sense to use its functions. So, ideally we should have our own implementations for as much stuff as possible, but use it based on config options. And currently we clearly lacking on general and consistent support for "our own stuff", so would be nice to boost that. |
|
Main issue at hand is that if we allow %q in printf strings, then we can't swap in a system provided verision. |
|
Yeah - I agree. Let's hold of on this for a while. We should probably cleanup all of the printf usage (except perhaps for debug stuff) and then make a decision. |
|
Ok, agree. Tidy up and consolidate printf first. |
|
Superseded by #1179. |
This commit replaces the literal calls to `esptool.py` with the
`$(ESPTOOL)` Makefile variable. This allows one to set the esptool
invocation on the Make command line:
make ESPTOOL="python2 $(which esptool.py)"
(or via the environment, an include file, etc)
Closes micropython#793
This allows us to use print("%q", some_qstr) instead
of print("%s", qstr_str(some_qstr))
This has a net savings of 68 bytes on the stmhal port.