Merge pull request #1860 from godlygeek/int_to_bytes_overflow_checks

Add overflow checks for int to bytes conversions
This commit is contained in:
Scott Shawcroft 2019-05-10 12:23:31 -07:00 committed by GitHub
commit da2c88eaac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 303 additions and 83 deletions

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-05-08 15:23-0700\n"
"POT-Creation-Date: 2019-05-09 01:06-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -52,8 +52,8 @@ msgstr ""
msgid "%q indices must be integers, not %s"
msgstr ""
#: shared-bindings/bleio/CharacteristicBuffer.c
#: shared-bindings/displayio/Group.c shared-bindings/displayio/Shape.c
#: shared-bindings/bleio/CharacteristicBuffer.c
#, fuzzy
msgid "%q must be >= 1"
msgstr "buffers harus mempunyai panjang yang sama"
@ -253,8 +253,8 @@ msgstr "Semua channel event yang disinkronisasi sedang digunakan"
msgid "All timers for this pin are in use"
msgstr "Semua timer untuk pin ini sedang digunakan"
#: ports/atmel-samd/common-hal/audioio/AudioOut.c
#: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c
#: ports/atmel-samd/common-hal/audioio/AudioOut.c
#: ports/atmel-samd/common-hal/pulseio/PulseOut.c
#: ports/nrf/common-hal/pulseio/PulseOut.c shared-bindings/pulseio/PWMOut.c
#: shared-module/_pew/PewPew.c
@ -751,8 +751,8 @@ msgstr ""
msgid "Input/output error"
msgstr ""
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
msgid "Invalid %q pin"
msgstr "%q pada tidak valid"
@ -1076,8 +1076,8 @@ msgstr ""
msgid "Sample rate too high. It must be less than %d"
msgstr "Nilai sampel terlalu tinggi. Nilai harus kurang dari %d"
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
msgid "Serializer in use"
msgstr "Serializer sedang digunakan"
@ -1216,8 +1216,8 @@ msgstr ""
msgid "Unable to allocate buffers for signed conversion"
msgstr "Tidak dapat mengalokasikan buffer untuk signed conversion"
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
msgid "Unable to find free GCLK"
msgstr "Tidak dapat menemukan GCLK yang kosong"
@ -1709,7 +1709,7 @@ msgstr ""
msgid "empty"
msgstr ""
#: extmod/moduheapq.c extmod/modutimeq.c
#: extmod/modutimeq.c extmod/moduheapq.c
msgid "empty heap"
msgstr "heap kosong"
@ -2586,6 +2586,11 @@ msgstr ""
msgid "unsupported types for %q: '%s', '%s'"
msgstr ""
#: py/objint.c
#, c-format
msgid "value would overflow a %d byte buffer"
msgstr ""
#: shared-bindings/displayio/Bitmap.c
msgid "value_count must be > 0"
msgstr ""

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-05-08 15:23-0700\n"
"POT-Creation-Date: 2019-05-10 10:09-0700\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -2539,6 +2539,11 @@ msgstr ""
msgid "unsupported types for %q: '%s', '%s'"
msgstr ""
#: py/objint.c
#, c-format
msgid "value would overflow a %d byte buffer"
msgstr ""
#: shared-bindings/displayio/Bitmap.c
msgid "value_count must be > 0"
msgstr ""

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-05-08 15:23-0700\n"
"POT-Creation-Date: 2019-05-09 01:06-0400\n"
"PO-Revision-Date: 2018-07-27 11:55-0700\n"
"Last-Translator: Pascal Deneaux\n"
"Language-Team: Sebastian Plamauer, Pascal Deneaux\n"
@ -54,8 +54,8 @@ msgstr "Der Index %q befindet sich außerhalb der Reihung"
msgid "%q indices must be integers, not %s"
msgstr "%q Indizes müssen ganze Zahlen sein, nicht %s"
#: shared-bindings/bleio/CharacteristicBuffer.c
#: shared-bindings/displayio/Group.c shared-bindings/displayio/Shape.c
#: shared-bindings/bleio/CharacteristicBuffer.c
msgid "%q must be >= 1"
msgstr "%q muss >= 1 sein"
@ -253,8 +253,8 @@ msgstr "Alle sync event Kanäle werden benutzt"
msgid "All timers for this pin are in use"
msgstr "Alle timer für diesen Pin werden bereits benutzt"
#: ports/atmel-samd/common-hal/audioio/AudioOut.c
#: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c
#: ports/atmel-samd/common-hal/audioio/AudioOut.c
#: ports/atmel-samd/common-hal/pulseio/PulseOut.c
#: ports/nrf/common-hal/pulseio/PulseOut.c shared-bindings/pulseio/PWMOut.c
#: shared-module/_pew/PewPew.c
@ -732,8 +732,8 @@ msgstr ""
msgid "Input/output error"
msgstr "Eingabe-/Ausgabefehler"
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
msgid "Invalid %q pin"
msgstr "Ungültiger %q pin"
@ -1063,8 +1063,8 @@ msgstr "Abtastrate muss positiv sein"
msgid "Sample rate too high. It must be less than %d"
msgstr "Abtastrate zu hoch. Wert muss unter %d liegen"
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
msgid "Serializer in use"
msgstr "Serializer wird benutzt"
@ -1212,8 +1212,8 @@ msgstr "Der UUID-Wert ist kein str-, int- oder Byte-Puffer"
msgid "Unable to allocate buffers for signed conversion"
msgstr "Konnte keine Buffer für Vorzeichenumwandlung allozieren"
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
msgid "Unable to find free GCLK"
msgstr "Konnte keinen freien GCLK finden"
@ -1705,7 +1705,7 @@ msgstr "Division durch Null"
msgid "empty"
msgstr "leer"
#: extmod/moduheapq.c extmod/modutimeq.c
#: extmod/modutimeq.c extmod/moduheapq.c
msgid "empty heap"
msgstr "leerer heap"
@ -2595,6 +2595,11 @@ msgstr "nicht unterstützter Typ für Operator"
msgid "unsupported types for %q: '%s', '%s'"
msgstr "nicht unterstützte Typen für %q: '%s', '%s'"
#: py/objint.c
#, c-format
msgid "value would overflow a %d byte buffer"
msgstr ""
#: shared-bindings/displayio/Bitmap.c
msgid "value_count must be > 0"
msgstr ""

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-05-08 15:23-0700\n"
"POT-Creation-Date: 2019-05-09 01:06-0400\n"
"PO-Revision-Date: 2018-07-27 11:55-0700\n"
"Last-Translator: \n"
"Language-Team: \n"
@ -52,8 +52,8 @@ msgstr ""
msgid "%q indices must be integers, not %s"
msgstr ""
#: shared-bindings/bleio/CharacteristicBuffer.c
#: shared-bindings/displayio/Group.c shared-bindings/displayio/Shape.c
#: shared-bindings/bleio/CharacteristicBuffer.c
msgid "%q must be >= 1"
msgstr ""
@ -251,8 +251,8 @@ msgstr ""
msgid "All timers for this pin are in use"
msgstr ""
#: ports/atmel-samd/common-hal/audioio/AudioOut.c
#: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c
#: ports/atmel-samd/common-hal/audioio/AudioOut.c
#: ports/atmel-samd/common-hal/pulseio/PulseOut.c
#: ports/nrf/common-hal/pulseio/PulseOut.c shared-bindings/pulseio/PWMOut.c
#: shared-module/_pew/PewPew.c
@ -726,8 +726,8 @@ msgstr ""
msgid "Input/output error"
msgstr ""
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
msgid "Invalid %q pin"
msgstr ""
@ -1046,8 +1046,8 @@ msgstr ""
msgid "Sample rate too high. It must be less than %d"
msgstr ""
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
msgid "Serializer in use"
msgstr ""
@ -1183,8 +1183,8 @@ msgstr ""
msgid "Unable to allocate buffers for signed conversion"
msgstr ""
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
msgid "Unable to find free GCLK"
msgstr ""
@ -1665,7 +1665,7 @@ msgstr ""
msgid "empty"
msgstr ""
#: extmod/moduheapq.c extmod/modutimeq.c
#: extmod/modutimeq.c extmod/moduheapq.c
msgid "empty heap"
msgstr ""
@ -2539,6 +2539,11 @@ msgstr ""
msgid "unsupported types for %q: '%s', '%s'"
msgstr ""
#: py/objint.c
#, c-format
msgid "value would overflow a %d byte buffer"
msgstr ""
#: shared-bindings/displayio/Bitmap.c
msgid "value_count must be > 0"
msgstr ""

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-05-08 15:23-0700\n"
"POT-Creation-Date: 2019-05-09 01:06-0400\n"
"PO-Revision-Date: 2018-07-27 11:55-0700\n"
"Last-Translator: \n"
"Language-Team: @sommersoft, @MrCertainly\n"
@ -54,8 +54,8 @@ msgstr ""
msgid "%q indices must be integers, not %s"
msgstr ""
#: shared-bindings/bleio/CharacteristicBuffer.c
#: shared-bindings/displayio/Group.c shared-bindings/displayio/Shape.c
#: shared-bindings/bleio/CharacteristicBuffer.c
msgid "%q must be >= 1"
msgstr ""
@ -253,8 +253,8 @@ msgstr ""
msgid "All timers for this pin are in use"
msgstr ""
#: ports/atmel-samd/common-hal/audioio/AudioOut.c
#: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c
#: ports/atmel-samd/common-hal/audioio/AudioOut.c
#: ports/atmel-samd/common-hal/pulseio/PulseOut.c
#: ports/nrf/common-hal/pulseio/PulseOut.c shared-bindings/pulseio/PWMOut.c
#: shared-module/_pew/PewPew.c
@ -730,8 +730,8 @@ msgstr ""
msgid "Input/output error"
msgstr ""
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
msgid "Invalid %q pin"
msgstr "Avast! %q pin be invalid"
@ -1050,8 +1050,8 @@ msgstr ""
msgid "Sample rate too high. It must be less than %d"
msgstr ""
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
msgid "Serializer in use"
msgstr ""
@ -1187,8 +1187,8 @@ msgstr ""
msgid "Unable to allocate buffers for signed conversion"
msgstr ""
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
msgid "Unable to find free GCLK"
msgstr "Arr! No free GCLK be in sight"
@ -1669,7 +1669,7 @@ msgstr ""
msgid "empty"
msgstr ""
#: extmod/moduheapq.c extmod/modutimeq.c
#: extmod/modutimeq.c extmod/moduheapq.c
msgid "empty heap"
msgstr ""
@ -2543,6 +2543,11 @@ msgstr ""
msgid "unsupported types for %q: '%s', '%s'"
msgstr ""
#: py/objint.c
#, c-format
msgid "value would overflow a %d byte buffer"
msgstr ""
#: shared-bindings/displayio/Bitmap.c
msgid "value_count must be > 0"
msgstr ""

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-05-08 15:23-0700\n"
"POT-Creation-Date: 2019-05-09 01:06-0400\n"
"PO-Revision-Date: 2018-08-24 22:56-0500\n"
"Last-Translator: \n"
"Language-Team: \n"
@ -55,8 +55,8 @@ msgstr "%q indice fuera de rango"
msgid "%q indices must be integers, not %s"
msgstr "%q indices deben ser enteros, no %s"
#: shared-bindings/bleio/CharacteristicBuffer.c
#: shared-bindings/displayio/Group.c shared-bindings/displayio/Shape.c
#: shared-bindings/bleio/CharacteristicBuffer.c
#, fuzzy
msgid "%q must be >= 1"
msgstr "%q debe ser >= 1"
@ -260,8 +260,8 @@ msgstr ""
msgid "All timers for this pin are in use"
msgstr "Todos los timers para este pin están siendo utilizados"
#: ports/atmel-samd/common-hal/audioio/AudioOut.c
#: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c
#: ports/atmel-samd/common-hal/audioio/AudioOut.c
#: ports/atmel-samd/common-hal/pulseio/PulseOut.c
#: ports/nrf/common-hal/pulseio/PulseOut.c shared-bindings/pulseio/PWMOut.c
#: shared-module/_pew/PewPew.c
@ -762,8 +762,8 @@ msgstr "Tamaño incorrecto del buffer"
msgid "Input/output error"
msgstr "error Input/output"
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
msgid "Invalid %q pin"
msgstr "Pin %q inválido"
@ -1096,8 +1096,8 @@ msgstr "Sample rate debe ser positivo"
msgid "Sample rate too high. It must be less than %d"
msgstr "Frecuencia de muestreo demasiado alta. Debe ser menor a %d"
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
msgid "Serializer in use"
msgstr "Serializer está siendo utilizado"
@ -1240,8 +1240,8 @@ msgstr "El valor UUID no es str, int, or buffer byte"
msgid "Unable to allocate buffers for signed conversion"
msgstr "No se pudieron asignar buffers para la conversión con signo"
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
msgid "Unable to find free GCLK"
msgstr "No se pudo encontrar un GCLK libre"
@ -1740,7 +1740,7 @@ msgstr "división por cero"
msgid "empty"
msgstr "vacío"
#: extmod/moduheapq.c extmod/modutimeq.c
#: extmod/modutimeq.c extmod/moduheapq.c
msgid "empty heap"
msgstr "heap vacío"
@ -2629,6 +2629,11 @@ msgstr "tipo de operador no soportado"
msgid "unsupported types for %q: '%s', '%s'"
msgstr "tipos no soportados para %q: '%s', '%s'"
#: py/objint.c
#, c-format
msgid "value would overflow a %d byte buffer"
msgstr ""
#: shared-bindings/displayio/Bitmap.c
msgid "value_count must be > 0"
msgstr "value_count debe ser > 0"

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-05-08 15:23-0700\n"
"POT-Creation-Date: 2019-05-09 01:06-0400\n"
"PO-Revision-Date: 2018-12-20 22:15-0800\n"
"Last-Translator: Timothy <me@timothygarcia.ca>\n"
"Language-Team: fil\n"
@ -52,8 +52,8 @@ msgstr "%q indeks wala sa sakop"
msgid "%q indices must be integers, not %s"
msgstr "%q indeks ay dapat integers, hindi %s"
#: shared-bindings/bleio/CharacteristicBuffer.c
#: shared-bindings/displayio/Group.c shared-bindings/displayio/Shape.c
#: shared-bindings/bleio/CharacteristicBuffer.c
#, fuzzy
msgid "%q must be >= 1"
msgstr "aarehas na haba dapat ang buffer slices"
@ -255,8 +255,8 @@ msgstr "Lahat ng sync event channels ay ginagamit"
msgid "All timers for this pin are in use"
msgstr "Lahat ng timers para sa pin na ito ay ginagamit"
#: ports/atmel-samd/common-hal/audioio/AudioOut.c
#: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c
#: ports/atmel-samd/common-hal/audioio/AudioOut.c
#: ports/atmel-samd/common-hal/pulseio/PulseOut.c
#: ports/nrf/common-hal/pulseio/PulseOut.c shared-bindings/pulseio/PWMOut.c
#: shared-module/_pew/PewPew.c
@ -756,8 +756,8 @@ msgstr ""
msgid "Input/output error"
msgstr "May mali sa Input/Output"
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
msgid "Invalid %q pin"
msgstr "Mali ang %q pin"
@ -1089,8 +1089,8 @@ msgstr "Sample rate ay dapat positibo"
msgid "Sample rate too high. It must be less than %d"
msgstr "Sample rate ay masyadong mataas. Ito ay dapat hindi hiigit sa %d"
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
msgid "Serializer in use"
msgstr "Serializer ginagamit"
@ -1236,8 +1236,8 @@ msgstr ""
msgid "Unable to allocate buffers for signed conversion"
msgstr "Hindi ma-allocate ang buffers para sa naka-sign na conversion"
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
msgid "Unable to find free GCLK"
msgstr "Hindi mahanap ang libreng GCLK"
@ -1739,7 +1739,7 @@ msgstr "dibisyon ng zero"
msgid "empty"
msgstr "walang laman"
#: extmod/moduheapq.c extmod/modutimeq.c
#: extmod/modutimeq.c extmod/moduheapq.c
msgid "empty heap"
msgstr "walang laman ang heap"
@ -2627,6 +2627,11 @@ msgstr "hindi sinusuportahang type para sa operator"
msgid "unsupported types for %q: '%s', '%s'"
msgstr "hindi sinusuportahang type para sa %q: '%s', '%s'"
#: py/objint.c
#, c-format
msgid "value would overflow a %d byte buffer"
msgstr ""
#: shared-bindings/displayio/Bitmap.c
msgid "value_count must be > 0"
msgstr ""

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: 0.1\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-05-08 15:23-0700\n"
"POT-Creation-Date: 2019-05-09 01:06-0400\n"
"PO-Revision-Date: 2019-04-14 20:05+0100\n"
"Last-Translator: Pierrick Couturier <arofarn@arofarn.info>\n"
"Language-Team: fr\n"
@ -54,8 +54,8 @@ msgstr "index %q hors gamme"
msgid "%q indices must be integers, not %s"
msgstr "les indices %q doivent être des entiers, pas %s"
#: shared-bindings/bleio/CharacteristicBuffer.c
#: shared-bindings/displayio/Group.c shared-bindings/displayio/Shape.c
#: shared-bindings/bleio/CharacteristicBuffer.c
#, fuzzy
msgid "%q must be >= 1"
msgstr "%d doit être >=1"
@ -258,8 +258,8 @@ msgstr "Tous les canaux d'événements de synchro sont utilisés"
msgid "All timers for this pin are in use"
msgstr "Tous les timers pour cette broche sont utilisés"
#: ports/atmel-samd/common-hal/audioio/AudioOut.c
#: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c
#: ports/atmel-samd/common-hal/audioio/AudioOut.c
#: ports/atmel-samd/common-hal/pulseio/PulseOut.c
#: ports/nrf/common-hal/pulseio/PulseOut.c shared-bindings/pulseio/PWMOut.c
#: shared-module/_pew/PewPew.c
@ -760,8 +760,8 @@ msgstr "Taille de tampon incorrecte"
msgid "Input/output error"
msgstr "Erreur d'entrée/sortie"
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
msgid "Invalid %q pin"
msgstr "Broche invalide pour '%q'"
@ -1105,8 +1105,8 @@ msgstr "Le taux d'échantillonage doit être positif"
msgid "Sample rate too high. It must be less than %d"
msgstr "Taux d'échantillonage trop élevé. Doit être inf. à %d"
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
msgid "Serializer in use"
msgstr "Sérialiseur en cours d'utilisation"
@ -1259,8 +1259,8 @@ msgstr ""
msgid "Unable to allocate buffers for signed conversion"
msgstr "Impossible d'allouer des tampons pour une conversion signée"
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
msgid "Unable to find free GCLK"
msgstr "Impossible de trouver un GCLK libre"
@ -1772,7 +1772,7 @@ msgstr "division par zéro"
msgid "empty"
msgstr "vide"
#: extmod/moduheapq.c extmod/modutimeq.c
#: extmod/modutimeq.c extmod/moduheapq.c
msgid "empty heap"
msgstr "tas vide"
@ -2669,6 +2669,11 @@ msgstr "type non supporté pour l'opérateur"
msgid "unsupported types for %q: '%s', '%s'"
msgstr "type non supporté pour %q: '%s', '%s'"
#: py/objint.c
#, c-format
msgid "value would overflow a %d byte buffer"
msgstr ""
#: shared-bindings/displayio/Bitmap.c
msgid "value_count must be > 0"
msgstr "'value_count' doit être > 0"

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-05-08 15:23-0700\n"
"POT-Creation-Date: 2019-05-09 01:06-0400\n"
"PO-Revision-Date: 2018-10-02 16:27+0200\n"
"Last-Translator: Enrico Paganin <enrico.paganin@mail.com>\n"
"Language-Team: \n"
@ -52,8 +52,8 @@ msgstr "indice %q fuori intervallo"
msgid "%q indices must be integers, not %s"
msgstr "gli indici %q devono essere interi, non %s"
#: shared-bindings/bleio/CharacteristicBuffer.c
#: shared-bindings/displayio/Group.c shared-bindings/displayio/Shape.c
#: shared-bindings/bleio/CharacteristicBuffer.c
#, fuzzy
msgid "%q must be >= 1"
msgstr "slice del buffer devono essere della stessa lunghezza"
@ -254,8 +254,8 @@ msgstr "Tutti i canali di eventi sincronizzati in uso"
msgid "All timers for this pin are in use"
msgstr "Tutti i timer per questo pin sono in uso"
#: ports/atmel-samd/common-hal/audioio/AudioOut.c
#: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c
#: ports/atmel-samd/common-hal/audioio/AudioOut.c
#: ports/atmel-samd/common-hal/pulseio/PulseOut.c
#: ports/nrf/common-hal/pulseio/PulseOut.c shared-bindings/pulseio/PWMOut.c
#: shared-module/_pew/PewPew.c
@ -755,8 +755,8 @@ msgstr ""
msgid "Input/output error"
msgstr "Errore input/output"
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
msgid "Invalid %q pin"
msgstr "Pin %q non valido"
@ -1095,8 +1095,8 @@ msgid "Sample rate too high. It must be less than %d"
msgstr ""
"Frequenza di campionamento troppo alta. Il valore deve essere inferiore a %d"
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
msgid "Serializer in use"
msgstr "Serializer in uso"
@ -1235,8 +1235,8 @@ msgstr ""
msgid "Unable to allocate buffers for signed conversion"
msgstr "Ipossibilitato ad allocare buffer per la conversione con segno"
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
msgid "Unable to find free GCLK"
msgstr "Impossibile trovare un GCLK libero"
@ -1731,7 +1731,7 @@ msgstr "divisione per zero"
msgid "empty"
msgstr "vuoto"
#: extmod/moduheapq.c extmod/modutimeq.c
#: extmod/modutimeq.c extmod/moduheapq.c
msgid "empty heap"
msgstr "heap vuoto"
@ -2625,6 +2625,11 @@ msgstr "tipo non supportato per l'operando"
msgid "unsupported types for %q: '%s', '%s'"
msgstr "tipi non supportati per %q: '%s', '%s'"
#: py/objint.c
#, c-format
msgid "value would overflow a %d byte buffer"
msgstr ""
#: shared-bindings/displayio/Bitmap.c
msgid "value_count must be > 0"
msgstr ""

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-05-08 15:23-0700\n"
"POT-Creation-Date: 2019-05-09 01:06-0400\n"
"PO-Revision-Date: 2019-03-19 18:37-0700\n"
"Last-Translator: Radomir Dopieralski <circuitpython@sheep.art.pl>\n"
"Language-Team: pl\n"
@ -53,8 +53,8 @@ msgstr "%q poza zakresem"
msgid "%q indices must be integers, not %s"
msgstr "%q indeks musi być liczbą całkowitą, a nie %s"
#: shared-bindings/bleio/CharacteristicBuffer.c
#: shared-bindings/displayio/Group.c shared-bindings/displayio/Shape.c
#: shared-bindings/bleio/CharacteristicBuffer.c
msgid "%q must be >= 1"
msgstr "%q musi być >= 1"
@ -252,8 +252,8 @@ msgstr "Wszystkie kanały zdarzeń synchronizacji w użyciu"
msgid "All timers for this pin are in use"
msgstr "Wszystkie timery tej nóżki w użyciu"
#: ports/atmel-samd/common-hal/audioio/AudioOut.c
#: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c
#: ports/atmel-samd/common-hal/audioio/AudioOut.c
#: ports/atmel-samd/common-hal/pulseio/PulseOut.c
#: ports/nrf/common-hal/pulseio/PulseOut.c shared-bindings/pulseio/PWMOut.c
#: shared-module/_pew/PewPew.c
@ -731,8 +731,8 @@ msgstr "Niewłaściwa wielkość bufora"
msgid "Input/output error"
msgstr "Błąd I/O"
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
msgid "Invalid %q pin"
msgstr "Zła nóżka %q"
@ -1056,8 +1056,8 @@ msgstr "Częstotliwość próbkowania musi być dodatnia"
msgid "Sample rate too high. It must be less than %d"
msgstr "Zbyt wysoka częstotliwość próbkowania. Musi być mniejsza niż %d"
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
msgid "Serializer in use"
msgstr "Serializator w użyciu"
@ -1203,8 +1203,8 @@ msgstr "UUID nie jest typu str, int lub bytes"
msgid "Unable to allocate buffers for signed conversion"
msgstr "Nie udała się alokacja buforów do konwersji ze znakiem"
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
msgid "Unable to find free GCLK"
msgstr "Brak wolnego GCLK"
@ -1690,7 +1690,7 @@ msgstr "dzielenie przez zero"
msgid "empty"
msgstr "puste"
#: extmod/moduheapq.c extmod/modutimeq.c
#: extmod/modutimeq.c extmod/moduheapq.c
msgid "empty heap"
msgstr "pusta sterta"
@ -2566,6 +2566,11 @@ msgstr "zły typ dla operatora"
msgid "unsupported types for %q: '%s', '%s'"
msgstr "złe typy dla %q: '%s', '%s'"
#: py/objint.c
#, c-format
msgid "value would overflow a %d byte buffer"
msgstr ""
#: shared-bindings/displayio/Bitmap.c
msgid "value_count must be > 0"
msgstr "value_count musi być > 0"

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-05-08 15:23-0700\n"
"POT-Creation-Date: 2019-05-09 01:06-0400\n"
"PO-Revision-Date: 2018-10-02 21:14-0000\n"
"Last-Translator: \n"
"Language-Team: \n"
@ -52,8 +52,8 @@ msgstr ""
msgid "%q indices must be integers, not %s"
msgstr ""
#: shared-bindings/bleio/CharacteristicBuffer.c
#: shared-bindings/displayio/Group.c shared-bindings/displayio/Shape.c
#: shared-bindings/bleio/CharacteristicBuffer.c
#, fuzzy
msgid "%q must be >= 1"
msgstr "buffers devem ser o mesmo tamanho"
@ -254,8 +254,8 @@ msgstr ""
msgid "All timers for this pin are in use"
msgstr "Todos os temporizadores para este pino estão em uso"
#: ports/atmel-samd/common-hal/audioio/AudioOut.c
#: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c
#: ports/atmel-samd/common-hal/audioio/AudioOut.c
#: ports/atmel-samd/common-hal/pulseio/PulseOut.c
#: ports/nrf/common-hal/pulseio/PulseOut.c shared-bindings/pulseio/PWMOut.c
#: shared-module/_pew/PewPew.c
@ -746,8 +746,8 @@ msgstr ""
msgid "Input/output error"
msgstr ""
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
msgid "Invalid %q pin"
msgstr "Pino do %q inválido"
@ -1074,8 +1074,8 @@ msgstr ""
msgid "Sample rate too high. It must be less than %d"
msgstr "Taxa de amostragem muito alta. Deve ser menor que %d"
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
msgid "Serializer in use"
msgstr "Serializer em uso"
@ -1211,8 +1211,8 @@ msgstr ""
msgid "Unable to allocate buffers for signed conversion"
msgstr "Não é possível alocar buffers para conversão assinada"
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
msgid "Unable to find free GCLK"
msgstr "Não é possível encontrar GCLK livre"
@ -1697,7 +1697,7 @@ msgstr "divisão por zero"
msgid "empty"
msgstr "vazio"
#: extmod/moduheapq.c extmod/modutimeq.c
#: extmod/modutimeq.c extmod/moduheapq.c
msgid "empty heap"
msgstr "heap vazia"
@ -2576,6 +2576,11 @@ msgstr ""
msgid "unsupported types for %q: '%s', '%s'"
msgstr ""
#: py/objint.c
#, c-format
msgid "value would overflow a %d byte buffer"
msgstr ""
#: shared-bindings/displayio/Bitmap.c
msgid "value_count must be > 0"
msgstr ""

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: circuitpython-cn\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-05-08 15:23-0700\n"
"POT-Creation-Date: 2019-05-09 01:06-0400\n"
"PO-Revision-Date: 2019-04-13 10:10-0700\n"
"Last-Translator: hexthat\n"
"Language-Team: Chinese Hanyu Pinyin\n"
@ -54,8 +54,8 @@ msgstr "%q suǒyǐn chāochū fànwéi"
msgid "%q indices must be integers, not %s"
msgstr "%q suǒyǐn bìxū shì zhěngshù, ér bùshì %s"
#: shared-bindings/bleio/CharacteristicBuffer.c
#: shared-bindings/displayio/Group.c shared-bindings/displayio/Shape.c
#: shared-bindings/bleio/CharacteristicBuffer.c
msgid "%q must be >= 1"
msgstr "%q bìxū dàyú huò děngyú 1"
@ -253,8 +253,8 @@ msgstr "Suǒyǒu tóngbù shìjiàn píndào shǐyòng"
msgid "All timers for this pin are in use"
msgstr "Cǐ yǐn jiǎo de suǒyǒu jìshí qì zhèngzài shǐyòng"
#: ports/atmel-samd/common-hal/audioio/AudioOut.c
#: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c
#: ports/atmel-samd/common-hal/audioio/AudioOut.c
#: ports/atmel-samd/common-hal/pulseio/PulseOut.c
#: ports/nrf/common-hal/pulseio/PulseOut.c shared-bindings/pulseio/PWMOut.c
#: shared-module/_pew/PewPew.c
@ -732,8 +732,8 @@ msgstr "Huǎnchōng qū dàxiǎo bù zhèngquè"
msgid "Input/output error"
msgstr "Shūrù/shūchū cuòwù"
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
msgid "Invalid %q pin"
msgstr "Wúxiào de %q yǐn jiǎo"
@ -1061,8 +1061,8 @@ msgstr "Cǎiyàng lǜ bìxū wèi zhèng shù"
msgid "Sample rate too high. It must be less than %d"
msgstr "Cǎiyàng lǜ tài gāo. Tā bìxū xiǎoyú %d"
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
msgid "Serializer in use"
msgstr "Xùliè huà yǐjīng shǐyòngguò"
@ -1208,8 +1208,8 @@ msgstr "UUID zhí bùshì str,int huò zì jié huǎnchōng qū"
msgid "Unable to allocate buffers for signed conversion"
msgstr "Wúfǎ fēnpèi huǎnchōng qū yòng yú qiānmíng zhuǎnhuàn"
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
#: ports/atmel-samd/common-hal/audiobusio/PDMIn.c
#: ports/atmel-samd/common-hal/audiobusio/I2SOut.c
msgid "Unable to find free GCLK"
msgstr "Wúfǎ zhǎodào miǎnfèi de GCLK"
@ -1700,7 +1700,7 @@ msgstr "bèi líng chú"
msgid "empty"
msgstr "kòngxián"
#: extmod/moduheapq.c extmod/modutimeq.c
#: extmod/modutimeq.c extmod/moduheapq.c
msgid "empty heap"
msgstr "kōng yīn yīnxiào"
@ -2578,6 +2578,11 @@ msgstr "bù zhīchí de cāozuò zhě lèixíng"
msgid "unsupported types for %q: '%s', '%s'"
msgstr "bù zhīchí de lèixíng wèi %q: '%s', '%s'"
#: py/objint.c
#, c-format
msgid "value would overflow a %d byte buffer"
msgstr ""
#: shared-bindings/displayio/Bitmap.c
msgid "value_count must be > 0"
msgstr "zhí jìshù bìxū wèi > 0"

View File

@ -23,7 +23,7 @@ CIRCUITPY_SMALL_BUILD = 1
CHIP_VARIANT = SAMD21E18A
CHIP_FAMILY = samd21
CFLAGS_INLINE_LIMIT = 35
CFLAGS_INLINE_LIMIT = 25
# Include these Python libraries in firmware.
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_DotStar

View File

@ -304,15 +304,18 @@ void mp_binary_set_val(char struct_type, char val_type, mp_obj_t val_in, byte **
break;
}
#endif
default:
default: {
bool signed_type = is_signed(val_type);
#if MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_NONE
if (MP_OBJ_IS_TYPE(val_in, &mp_type_int)) {
mp_obj_int_buffer_overflow_check(val_in, size, signed_type);
mp_obj_int_to_bytes_impl(val_in, struct_type == '>', size, p);
return;
} else
#endif
{
val = mp_obj_get_int(val_in);
mp_obj_int_buffer_overflow_check(val_in, size, signed_type);
// zero/sign extend if needed
if (BYTES_PER_WORD < 8 && size > sizeof(val)) {
int c = (is_signed(val_type) && (mp_int_t)val < 0) ? 0xff : 0x00;
@ -322,6 +325,7 @@ void mp_binary_set_val(char struct_type, char val_type, mp_obj_t val_in, byte **
}
}
}
}
}
mp_binary_set_int(MIN((size_t)size, sizeof(val)), struct_type == '>', p, val);
@ -343,16 +347,22 @@ void mp_binary_set_val_array(char typecode, void *p, mp_uint_t index, mp_obj_t v
((mp_obj_t*)p)[index] = val_in;
break;
#endif
default:
default: {
size_t size = mp_binary_get_size('@', typecode, NULL);
bool signed_type = is_signed(typecode);
#if MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_NONE
if (MP_OBJ_IS_TYPE(val_in, &mp_type_int)) {
size_t size = mp_binary_get_size('@', typecode, NULL);
mp_obj_int_buffer_overflow_check(val_in, size, signed_type);
mp_obj_int_to_bytes_impl(val_in, MP_ENDIANNESS_BIG,
size, (uint8_t*)p + index * size);
return;
}
#endif
mp_binary_set_val_array_from_int(typecode, p, index, mp_obj_get_int(val_in));
mp_int_t val = mp_obj_get_int(val_in);
mp_obj_int_buffer_overflow_check(val_in, size, signed_type);
mp_binary_set_val_array_from_int(typecode, p, index, val);
}
}
}

View File

@ -300,6 +300,38 @@ char *mp_obj_int_formatted(char **buf, size_t *buf_size, size_t *fmt_size, mp_co
return b;
}
void mp_obj_int_buffer_overflow_check(mp_obj_t self_in, size_t nbytes, bool is_signed)
{
if (is_signed) {
// self must be < 2**(bits - 1)
mp_obj_t edge = mp_binary_op(MP_BINARY_OP_INPLACE_LSHIFT,
mp_obj_new_int(1),
mp_obj_new_int(nbytes * 8 - 1));
if (mp_binary_op(MP_BINARY_OP_LESS, self_in, edge) == mp_const_true) {
// and >= -2**(bits - 1)
edge = mp_unary_op(MP_UNARY_OP_NEGATIVE, edge);
if (mp_binary_op(MP_BINARY_OP_MORE_EQUAL, self_in, edge) == mp_const_true) {
return;
}
}
} else {
// self must be >= 0
if (mp_obj_int_sign(self_in) >= 0) {
// and < 2**(bits)
mp_obj_t edge = mp_binary_op(MP_BINARY_OP_INPLACE_LSHIFT,
mp_obj_new_int(1),
mp_obj_new_int(nbytes * 8));
if (mp_binary_op(MP_BINARY_OP_LESS, self_in, edge) == mp_const_true) {
return;
}
}
}
mp_raise_OverflowError_varg(translate("value would overflow a %d byte buffer"), nbytes);
}
#if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_NONE
int mp_obj_int_sign(mp_obj_t self_in) {
@ -435,6 +467,8 @@ STATIC mp_obj_t int_to_bytes(size_t n_args, const mp_obj_t *args) {
byte *data = (byte*)vstr.buf;
memset(data, 0, len);
mp_obj_int_buffer_overflow_check(args[0], len, false);
#if MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_NONE
if (!MP_OBJ_IS_SMALL_INT(args[0])) {
mp_obj_int_to_bytes_impl(args[0], big_endian, len, data);

View File

@ -53,6 +53,7 @@ char *mp_obj_int_formatted(char **buf, size_t *buf_size, size_t *fmt_size, mp_co
int base, const char *prefix, char base_char, char comma);
char *mp_obj_int_formatted_impl(char **buf, size_t *buf_size, size_t *fmt_size, mp_const_obj_t self_in,
int base, const char *prefix, char base_char, char comma);
void mp_obj_int_buffer_overflow_check(mp_obj_t self_in, size_t nbytes, bool is_signed);
mp_int_t mp_obj_int_hash(mp_obj_t self_in);
mp_obj_t mp_obj_int_from_bytes_impl(bool big_endian, size_t len, const byte *buf);
void mp_obj_int_to_bytes_impl(mp_obj_t self_in, bool big_endian, size_t len, byte *buf);

View File

@ -1598,6 +1598,14 @@ NORETURN void mp_raise_NotImplementedError_varg(const compressed_string_t *fmt,
nlr_raise(exception);
}
NORETURN void mp_raise_OverflowError_varg(const compressed_string_t *fmt, ...) {
va_list argptr;
va_start(argptr,fmt);
mp_obj_t exception = mp_obj_new_exception_msg_vlist(&mp_type_OverflowError, fmt, argptr);
va_end(argptr);
nlr_raise(exception);
}
NORETURN void mp_raise_MpyError(const compressed_string_t *msg) {
mp_raise_msg(&mp_type_MpyError, msg);
}

View File

@ -163,6 +163,7 @@ NORETURN void mp_raise_OSError_msg(const compressed_string_t *msg);
NORETURN void mp_raise_OSError_msg_varg(const compressed_string_t *fmt, ...);
NORETURN void mp_raise_NotImplementedError(const compressed_string_t *msg);
NORETURN void mp_raise_NotImplementedError_varg(const compressed_string_t *fmt, ...);
NORETURN void mp_raise_OverflowError_varg(const compressed_string_t *fmt, ...);
NORETURN void mp_raise_MpyError(const compressed_string_t *msg);
NORETURN void mp_raise_recursion_depth(void);

View File

@ -0,0 +1,35 @@
import skip_if
skip_if.no_bigint()
try:
from array import array
except ImportError:
print("SKIP")
raise SystemExit
def test_array_overflow(typecode, val):
try:
print(array(typecode, [val]))
except OverflowError:
print('OverflowError')
# small int -1
test_array_overflow('Q', -1)
test_array_overflow('L', -1)
test_array_overflow('I', -1)
test_array_overflow('H', -1)
test_array_overflow('B', -1)
# big int -1
test_array_overflow('Q', -2**64 // 2**64)
test_array_overflow('L', -2**64 // 2**64)
test_array_overflow('I', -2**64 // 2**64)
test_array_overflow('H', -2**64 // 2**64)
test_array_overflow('B', -2**64 // 2**64)
# big int 2**63
test_array_overflow('q', 2**63)
test_array_overflow('l', 2**63)
test_array_overflow('i', 2**63)
test_array_overflow('h', 2**63)
test_array_overflow('b', 2**63)

View File

@ -17,3 +17,15 @@ try:
(1).to_bytes(-1, "little")
except ValueError:
print("ValueError")
# too small buffer should raise an error
try:
(256).to_bytes(1, "little")
except OverflowError:
print("OverflowError")
# negative numbers should raise an error
try:
(-256).to_bytes(2, "little")
except OverflowError:
print("OverflowError")

View File

@ -15,3 +15,15 @@ print(ib.to_bytes(20, "big"))
# check that extra zero bytes don't change the internal int value
print(int.from_bytes(b + bytes(10), "little") == int.from_bytes(b, "little"))
# too small buffer should raise an error
try:
(2**64).to_bytes(8, "little")
except OverflowError:
print("OverflowError")
# negative numbers should raise an error
try:
(-2**64).to_bytes(9, "little")
except OverflowError:
print("OverflowError")

View File

@ -0,0 +1,47 @@
import skip_if
skip_if.no_bigint()
try:
import ustruct as struct
except:
try:
import struct
except ImportError:
print("SKIP")
raise SystemExit
def test_struct_overflow(typecode, val):
try:
print(struct.pack(typecode, val))
except OverflowError:
print('OverflowError')
except struct.error:
print('OverflowError')
# small int -1
test_struct_overflow('>Q', -1)
test_struct_overflow('>L', -1)
test_struct_overflow('>I', -1)
test_struct_overflow('>H', -1)
test_struct_overflow('>B', -1)
# big int -1
test_struct_overflow('>Q', -2**64 // 2**64)
test_struct_overflow('>L', -2**64 // 2**64)
test_struct_overflow('>I', -2**64 // 2**64)
test_struct_overflow('>H', -2**64 // 2**64)
test_struct_overflow('>B', -2**64 // 2**64)
# possibly small ints
test_struct_overflow('>q', 2**63)
test_struct_overflow('>l', 2**31)
test_struct_overflow('>i', 2**31)
test_struct_overflow('>h', 2**15)
test_struct_overflow('>b', 2**7)
# definitely big ints
test_struct_overflow('>q', 2**64 // 2**1)
test_struct_overflow('>l', 2**64 // 2**33)
test_struct_overflow('>i', 2**64 // 2**33)
test_struct_overflow('>h', 2**64 // 2**49)
test_struct_overflow('>b', 2**64 // 2**57)