Skip to content
Snippets Groups Projects
  • Paul Sokolovsky's avatar
    674e069b
    py/objarray: bytearray: Allow 2nd/3rd arg to constructor. · 674e069b
    Paul Sokolovsky authored
    If bytearray is constructed from str, a second argument of encoding is
    required (in CPython), and third arg of Unicode error handling is allowed,
    e.g.:
    
    bytearray("str", "utf-8", "strict")
    
    This is similar to bytes:
    
    bytes("str", "utf-8", "strict")
    
    This patch just allows to pass 2nd/3rd arguments to bytearray, but
    doesn't try to validate them to not impact code size. (This is also
    similar to how bytes constructor is handled, though it does a bit
    more validation, e.g. check that in case of str arg, encoding argument
    is passed.)
    674e069b
    History
    py/objarray: bytearray: Allow 2nd/3rd arg to constructor.
    Paul Sokolovsky authored
    If bytearray is constructed from str, a second argument of encoding is
    required (in CPython), and third arg of Unicode error handling is allowed,
    e.g.:
    
    bytearray("str", "utf-8", "strict")
    
    This is similar to bytes:
    
    bytes("str", "utf-8", "strict")
    
    This patch just allows to pass 2nd/3rd arguments to bytearray, but
    doesn't try to validate them to not impact code size. (This is also
    similar to how bytes constructor is handled, though it does a bit
    more validation, e.g. check that in case of str arg, encoding argument
    is passed.)
objarray.c 23.76 KiB