{"record":{"id":"3916d29295482e07","repo":"matplotlib/matplotlib","slug":"nonstandard-units-in-dvi-file","errorCode":null,"errorMessage":"Nonstandard units in dvi file","messagePattern":"Nonstandard units in dvi file","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"lib/matplotlib/dviread.py","lineNumber":551,"sourceCode":"            # checks whether a missing glyph has been used, and in that case\n            # skips the glyph definition.\n            self.fonts[k] = cbook._ExceptionInfo.from_exception(exc)\n            return\n        if c != 0 and tfm.checksum != 0 and c != tfm.checksum:\n            raise ValueError(f'tfm checksum mismatch: {n}')\n        try:\n            vf = _vffile(fontname)\n        except FileNotFoundError:\n            vf = None\n        self.fonts[k] = DviFont(scale=s, metrics=tfm, texname=n, vf=vf)\n\n    @_dispatch(247, state=_dvistate.pre, args=('u1', 'u4', 'u4', 'u4', 'u1'))\n    def _pre(self, i, num, den, mag, k):\n        self.file.read(k)  # comment in the dvi file\n        if i not in [2, 7]:  # 2: pdftex, luatex; 7: xetex\n            raise ValueError(f\"Unknown dvi format {i}\")\n        if num != 25400000 or den != 7227 * 2**16:\n            raise ValueError(\"Nonstandard units in dvi file\")\n            # meaning: TeX always uses those exact values, so it\n            # should be enough for us to support those\n            # (There are 72.27 pt to an inch so 7227 pt =\n            # 7227 * 2**16 sp to 100 in. The numerator is multiplied\n            # by 10^5 to get units of 10**-7 meters.)\n        if mag != 1000:\n            raise ValueError(\"Nonstandard magnification in dvi file\")\n            # meaning: LaTeX seems to frown on setting \\mag, so\n            # I think we can assume this is constant\n        self.state = _dvistate.outer\n\n    @_dispatch(248, state=_dvistate.outer)\n    def _post(self, _):\n        self.state = _dvistate.post_post\n        # TODO: actually read the postamble and finale?\n        # currently post_post just triggers closing the file\n\n    @_dispatch(249, args=())","sourceCodeStart":533,"sourceCodeEnd":569,"githubUrl":"https://github.com/matplotlib/matplotlib/blob/b379c1b69e012b142c0f496a52bcb30513802d72/lib/matplotlib/dviread.py#L533-L569","documentation":"Error \"Nonstandard units in dvi file\" thrown in matplotlib/matplotlib.","triggerScenarios":"Thrown at lib/matplotlib/dviread.py:551 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b379c1b69e012b142c0f496a52bcb30513802d72","analyzedAt":"2026-08-21T23:31:55.468Z","schemaVersion":2},"datasetVersion":"2026-08-22T04:17:13.399Z"}