Commit Graph

15252 Commits

Author SHA1 Message Date
Josh Klar
3a7a5ba686 py: Implement partial PEP-498 (f-string) support
This implements (most of) the PEP-498 spec for f-strings, with two
exceptions:

- raw f-strings (`fr` or `rf` prefixes) raise `NotImplementedError`
- one special corner case does not function as specified in the PEP
(more on that in a moment)

This is implemented in the core as a syntax translation, brute-forcing
all f-strings to run through `String.format`. For example, the statement
`x='world'; print(f'hello {x}')` gets translated *at a syntax level*
(injected into the lexer) to `x='world'; print('hello {}'.format(x))`.
While this may lead to weird column results in tracebacks, it seemed
like the fastest, most efficient, and *likely* most RAM-friendly option,
despite being implemented under the hood with a completely separate
`vstr_t`.

Since [string concatenation of adjacent literals is implemented in the
lexer](534b7c368d),
two side effects emerge:

- All strings with at least one f-string portion are concatenated into a
single literal which *must* be run through `String.format()` wholesale,
and:
- Concatenation of a raw string with interpolation characters with an
f-string will cause `IndexError`/`KeyError`, which is both different
from CPython *and* different from the corner case mentioned in the PEP
(which gave an example of the following:)

```python
x = 10
y = 'hi'
assert ('a' 'b' f'{x}' '{c}' f'str<{y:^4}>' 'd' 'e') == 'ab10{c}str< hi >de'
```

The above-linked commit detailed a pretty solid case for leaving string
concatenation in the lexer rather than putting it in the parser, and
undoing that decision would likely be disproportionately costly on
resources for the sake of a probably-low-impact corner case. An
alternative to become complaint with this corner case of the PEP would
be to revert to string concatenation in the parser *only when an
f-string is part of concatenation*, though I've done no investigation on
the difficulty or costs of doing this.

A decent set of tests is included. I've manually tested this on the
`unix` port on Linux and on a Feather M4 Express (`atmel-samd`) and
things seem sane.
2020-03-09 08:16:07 -05:00
Limor "Ladyada" Fried
83d5da95b7
Merge pull request #2684 from caternuson/doc_add_sensors
Add proximity and sound_level to Design Guide
2020-03-06 18:10:47 -05:00
caternuson
125409fe95 add proximity and sound_level 2020-03-06 13:31:08 -08:00
Jeff Epler
4fa90261a3
Merge pull request #2657 from tannewt/builtin_package
Support importing native modules in native packages.
2020-03-05 14:28:46 -06:00
Dan Halbert
e81930fb9e
Merge pull request #2681 from theacodes/disable-hid-on-sol
Disable the HID USB descriptor for Sol
2020-03-05 09:31:16 -05:00
Thea Flowers
409a4a9490 Disable the HID USB descriptor for Sol
It's not used and ends up being confusing for folks.
2020-03-04 23:22:46 -08:00
Scott Shawcroft
b4e1955526
Merge pull request #2583 from jepler/ulab
Add 'ulab' as an extmod; enable on nrf and most samd51 boards
2020-03-04 11:46:17 -08:00
Scott Shawcroft
4aec5d1e83
Merge pull request #2680 from hierophect/stm32-clock-hotfix
STM32: Fix restriction on GPIO clock enables for F407 Discovery board
2020-03-04 11:43:33 -08:00
Jeff Epler
da31acfcc4 Merge remote-tracking branch 'origin/master' into ulab 2020-03-03 20:13:53 -06:00
Dan Halbert
e98991fd7e
Merge pull request #2678 from adafruit/5.0.x
Merge in 5.0.x changes
2020-03-03 17:31:36 -05:00
Lucian Copeland
55e13715a9 Expand GPIO clock enables for F405 and F407 2020-03-03 17:21:47 -05:00
Scott Shawcroft
6468ca04a4
Merge pull request #2668 from hierophect/stm32-pulseout
STM32: Add PulseOut support
2020-03-03 13:11:24 -08:00
hierophect
3178462218
Merge branch 'master' into stm32-pulseout 2020-03-03 15:03:19 -05:00
Scott Shawcroft
2fea811c30
Merge pull request #2672 from jepler/fuzz
Makefiles: add targets to build unix port, mpy-cross for fuzzing
2020-03-03 11:36:53 -08:00
Scott Shawcroft
17458ad81a
Merge pull request #2662 from jepler/issue2332
Fix unaligned disk reads properly
2020-03-03 11:27:50 -08:00
Scott Shawcroft
274cb597b0
Remove debug extern 2020-03-03 10:55:50 -08:00
Jeff Epler
c0bfa11766 Use tests from ulab extmod, instead of our own 2020-03-03 12:46:59 -06:00
Scott Shawcroft
2e370008c3
Merge pull request #2670 from jepler/compile-assertion-errors
Turn certain assertion errors in mpy-cross into SyntaxErrors
2020-03-03 10:11:36 -08:00
Lucian Copeland
eb71bfe9d3 Exclude SoCs without basic timers 2020-03-02 11:22:40 -05:00
Jeff Epler
402262a843 make translate 2020-03-02 09:13:06 -06:00
Dan Halbert
ba0c14f9dd
Merge pull request #2671 from dhalbert/merge-for-5.0.0-rc.1
Merge for 5.0.0 rc.1
2020-03-01 15:39:26 -05:00
Jeff Epler
74bf17bb0d Makefiles: add targets to build unix port, mpy-cross for fuzzing
This assumes you have properly install afl-fuzz with afl-clang-fast.
Tested with AFLplusplus 2.60c-75-g2c6847b.
2020-03-01 11:48:33 -06:00
Dan Halbert
898f67ac2e Merge branch 'master' into merge-for-5.0.0-rc.1 2020-03-01 12:22:18 -05:00
Dan Halbert
7528814617
Merge pull request #2664 from dhalbert/downloads-from-s3
Download links from S3; Do not upload release assets to GitHub
2020-03-01 11:43:55 -05:00
Jeff Epler
862830da32 compile: Give a proper error on 'async with'/'async for' outside 'async def'
A simple reproducer is:
   async for x in():x
2020-03-01 09:40:43 -06:00
Jeff Epler
511c180869 parse: push_result_token: throw an exception on too-long names
Before this, such names would instead cause an assertion error inside
qstr_from_strn.

A simple reproducer is a python source file containing the letter "a"
repeated 256 times
2020-03-01 09:38:34 -06:00
Jeff Epler
dc64857a7d
Merge branch 'master' into ulab 2020-02-29 21:54:39 -06:00
Lucian Copeland
6bb1649b4b Add translations 2020-02-29 14:52:49 -05:00
Lucian Copeland
611ef27ac2 stm32: Add PulseOut support
Matches the implementations of the NRF and Atmel ports. TIM7 is used as it does not have a tied pin. Contains some register micromanagement since HAL support for the TIM7 timer is limited.
2020-02-29 14:47:47 -05:00
Dan Halbert
98a03fc935 upload bin and uf2 for arduino boards; remove unneeded build steps 2020-02-28 21:18:48 -05:00
Dan Halbert
29e44721d2
Merge pull request #2665 from arturo182/esp32_freeze
Freeze adafruit_requests and adafruit_esp32spi into mimxrt1011 Feathers
2020-02-28 21:05:19 -05:00
arturo182
0af00cf914 Freeze adafruit_requests and adafruit_esp32spi into feather_m7_1011 2020-02-29 00:39:22 +01:00
arturo182
3f26a0b06b Freeze adafruit_requests and adafruit_esp32spi into feather_mimxrt1011 2020-02-29 00:26:39 +01:00
Dan Halbert
c24a4f7d66 change download prefix to https://downloads.circuitpython.org 2020-02-28 16:25:12 -05:00
Dan Halbert
1b8a4791f5 Download links now point to S3 via CloudFront 2020-02-28 14:57:32 -05:00
Jeff Epler
eef742bf45 oofatfs: Remove _FS_DISK_READ_ALIGNED
This workaround is no longer needed, so it can be removed.

Closes: #2332
2020-02-28 10:04:28 -06:00
Jeff Epler
1e6c08fc30 nrf: sqpi_flash: Handle unaligned reads 2020-02-28 10:03:37 -06:00
Dan Halbert
0c2894c725
Merge pull request #2659 from mubes/i2cfixes
Fix I2C clock divider
2020-02-28 10:55:48 -05:00
Jeff Epler
39cfe32c34 Update ulab from upstream again 2020-02-27 14:14:05 -06:00
Jeff Epler
645df931ae typos 2020-02-27 11:07:37 -06:00
Jeff Epler
fa3b9eba92 ulab: Incorporate it 2020-02-27 11:03:03 -06:00
Jeff Epler
4c710cf13b unix port: add help(), help('modules') 2020-02-27 08:31:01 -06:00
Jeff Epler
50438b51aa libm: Provide log2f 2020-02-27 08:30:12 -06:00
Jeff Epler
41e71485af libm: Disable float-equal diagnostics
I choose to believe these authors knew what they were doing.
2020-02-27 08:30:12 -06:00
Dave Marples
09a3153bf4 Fix I2C clock divider 2020-02-27 14:08:39 +00:00
Scott Shawcroft
6375d8699e
Validate builtin member is a module 2020-02-26 10:32:02 -08:00
arturo182
1b33cd11fc
Merge pull request #2658 from mubes/spi_fixes
Fix SPI clock speed on mimxrt10xx family & mimxrt1020 pinmux fixups
2020-02-26 16:37:05 +01:00
Dave Marples
aadb0bfc1e Fix SPI clock speed on mimxrt10xx family & mimxrt1020 pinmux fixup 2020-02-26 14:28:54 +00:00
Limor "Ladyada" Fried
3dc98a7a79
Merge pull request #2656 from ladyada/master
move red LED to D13 and make D3 lsm6ds IRQ
2020-02-25 18:34:40 -05:00
Scott Shawcroft
86fd93bd03
Support importing native modules in native packages.
This only fixes the `import` portion. It doesn't actually change
reference behavior because modules within a package could already
be referenced through the parent package even though an error should
have been thrown.
2020-02-25 15:32:55 -08:00