micropython/docs/library
Damien George 3c4bfd1dec py/objexcept: Support errno attribute on OSError exceptions.
This commit adds the errno attribute to exceptions, so code can retrieve
errno codes from an OSError using exc.errno.

The implementation here simply lets `errno` (and the existing `value`)
attributes work on any exception instance (they both alias args[0]).  This
is for efficiency and to keep code size down.  The pros and cons of this
are:

Pros:
- more compatible with CPython, less difference to document and learn
- OSError().errno will correctly return None, whereas the current way of
  doing it via OSError().args[0] will raise an IndexError
- it reduces code size on most bare-metal ports (because they already have
  the errno qstr)
- for Python code that uses exc.errno the generated bytecode is 2 bytes
  smaller and more efficient to execute (compared with exc.args[0]); so
  bytecode loaded to RAM saves 2 bytes RAM for each use of this attribute,
  and bytecode that is frozen saves 2 bytes flash/ROM for each use
- it's easier/shorter to type, and saves 2 bytes of space in .py files that
  use it (for each use)

Cons:
- increases code size by 4-8 bytes on minimal ports that don't already have
  the `errno` qstr
- all exceptions now have .errno and .value attributes (a cpydiff test is
  added to address this)

See also #2407.

Signed-off-by: Damien George <damien@micropython.org>
2021-04-23 22:03:46 +10:00
..
_thread.rst
btree.rst docs/library/btree.rst: Correct method typo: __detitem__ to __delitem__. 2020-10-20 17:13:02 +11:00
builtins.rst py/objexcept: Support errno attribute on OSError exceptions. 2021-04-23 22:03:46 +10:00
cmath.rst
esp.rst
esp32.rst esp32: Add basic support for Non-Volatile-Storage in esp32 module. 2021-02-19 15:05:19 +11:00
framebuf.rst
gc.rst
index.rst
lcd160cr.rst
machine.ADC.rst
machine.ADCWiPy.rst
machine.I2C.rst docs: Update I2C and SPI docs to add reference to SoftI2C and SoftSPI. 2020-10-01 12:57:10 +10:00
machine.Pin.rst docs/library/machine.Pin.rst: Make it clear which methods are not core. 2021-02-03 00:54:18 +11:00
machine.RTC.rst docs,stm32: Fix minor typos in RTC docs, and->an. 2021-01-30 14:13:30 +11:00
machine.SD.rst
machine.SDCard.rst
machine.SPI.rst docs: Update I2C and SPI docs to add reference to SoftI2C and SoftSPI. 2020-10-01 12:57:10 +10:00
machine.Signal.rst docs/library/machine.Signal.rst: Correct typo: usecases to use cases. 2020-10-20 17:21:30 +11:00
machine.Timer.rst docs/library/machine.Timer.rst: Add mention of constructor arguments. 2020-10-20 17:23:54 +11:00
machine.TimerWiPy.rst
machine.UART.rst
machine.WDT.rst
machine.rst docs/library/machine.rst: Correct minor typo: timout to timeout. 2020-10-20 17:19:47 +11:00
math.rst
micropython.rst
network.CC3K.rst
network.WIZNET5K.rst
network.WLAN.rst
network.WLANWiPy.rst
network.rst
pyb.ADC.rst
pyb.Accel.rst
pyb.CAN.rst stm32/pyb_can: Add ability to calculate CAN bit timing from baudrate. 2020-12-17 23:01:15 +11:00
pyb.DAC.rst
pyb.ExtInt.rst
pyb.Flash.rst
pyb.I2C.rst
pyb.LCD.rst
pyb.LED.rst
pyb.Pin.rst
pyb.RTC.rst docs,stm32: Fix minor typos in RTC docs, and->an. 2021-01-30 14:13:30 +11:00
pyb.SPI.rst
pyb.Servo.rst
pyb.Switch.rst
pyb.Timer.rst
pyb.UART.rst
pyb.USB_HID.rst
pyb.USB_VCP.rst
pyb.rst
uarray.rst
uasyncio.rst docs/library/uasyncio.rst: Add docs for ThreadSafeFlag. 2021-02-16 16:35:37 +11:00
ubinascii.rst extmod/modubinascii: Update code, docs for hexlify now CPython has sep. 2020-12-14 14:35:29 +11:00
ubluetooth.rst docs/library/ubluetooth.rst: Add passkey docs. 2020-12-02 14:44:36 +11:00
ucollections.rst
ucryptolib.rst
uctypes.rst
uerrno.rst py/objexcept: Support errno attribute on OSError exceptions. 2021-04-23 22:03:46 +10:00
uhashlib.rst
uheapq.rst
uio.rst
ujson.rst
uos.rst
ure.rst
uselect.rst
usocket.rst
ussl.rst extmod/modussl: Fix ussl read/recv/send/write errors when non-blocking. 2021-02-17 11:50:54 +11:00
ustruct.rst
usys.rst
utime.rst extmod/utime_mphal: Add generic utime.time_ns() function. 2020-10-01 14:20:42 +10:00
uzlib.rst
wipy.rst