Skip to content

Exception has occurred: UnicodeDecodeError 'utf-8' codec can't decode byte 0x96 in position 57: invalid start byte #77

Description

@mcninch

Parsing a standard STDF generated by Teradyne Ultraflex platform that contains ANSI characters not compatible with utf-8 causes UnicodeDecodeError to be thrown.

ANSI:

 =============  Test Suite – CONTINUITY ============= 

 500000     2     CONTINUITY        GPIO_00                     17.t406  -900.0000 mV   -434.4312 mV       -30.0000 mV    -1.0000 mA     0       
 500001     2     CONTINUITY        GPIO_01                     17.t412  -900.0000 mV   -434.1914 mV       -30.0000 mV    -1.0000 mA     0       
 500002     2     CONTINUITY        GPIO_02                     17.r412  -900.0000 mV   -435.3541 mV       -30.0000 mV    -1.0000 mA     0    

UTF-8:

 =============  Test Suite � CONTINUITY ============= 

 500000     2     CONTINUITY        GPIO_00                     17.t406  -900.0000 mV   -434.4312 mV       -30.0000 mV    -1.0000 mA     0       
 500001     2     CONTINUITY        GPIO_01                     17.t412  -900.0000 mV   -434.1914 mV       -30.0000 mV    -1.0000 mA     0       
 500002     2     CONTINUITY        GPIO_02                     17.r412  -900.0000 mV   -435.3541 mV       -30.0000 mV    -1.0000 mA     0    

Test code:

for REC in STDF.records_from_file(filename):
    record = REC.to_dict()

Error:
Exception has occurred: UnicodeDecodeError 'utf-8' codec can't decode byte 0x96 in position 57: invalid start byte

Image

 

Suggested Solution:
Change bytearray.decode() error handler from 'strict' to 'replace'

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions