{"record":{"id":"457312b68a4402b3","repo":"aosabook/500lines","slug":"global-name-s-is-not-defined","errorCode":null,"errorMessage":"global name '%s' is not defined","messagePattern":"global name '(.+?)' is not defined","errorType":"exception","errorClass":"NameError","httpStatus":null,"severity":"error","filePath":"interpreter/code/byterun/pyvm2.py","lineNumber":334,"sourceCode":"        if name in self.frame.local_names:\n            val = self.frame.local_names[name]\n        else:\n            raise UnboundLocalError(\n                \"local variable '%s' referenced before assignment\" % name\n            )\n        self.frame.push(val)\n\n    def byte_STORE_FAST(self, name):\n        self.frame.local_names[name] = self.frame.pop()\n\n    def byte_LOAD_GLOBAL(self, name):\n        f = self.frame\n        if name in f.global_names:\n            val = f.global_names[name]\n        elif name in f.builtin_names:\n            val = f.builtin_names[name]\n        else:\n            raise NameError(\"global name '%s' is not defined\" % name)\n        f.push(val)\n\n    ## Operators\n\n    UNARY_OPERATORS = {\n        'POSITIVE': operator.pos,\n        'NEGATIVE': operator.neg,\n        'NOT':      operator.not_,\n        'INVERT':   operator.invert,\n    }\n\n    def unaryOperator(self, op):\n        x = self.frame.pop()\n        self.frame.push(self.UNARY_OPERATORS[op](x))\n\n    BINARY_OPERATORS = {\n        'POWER':    pow,\n        'MULTIPLY': operator.mul,","sourceCodeStart":316,"sourceCodeEnd":352,"githubUrl":"https://github.com/aosabook/500lines/blob/fba689d101eb5600f5c8f4d7fd79912498e950e2/interpreter/code/byterun/pyvm2.py#L316-L352","documentation":"Error \"global name '%s' is not defined\" thrown in aosabook/500lines.","triggerScenarios":"Thrown at interpreter/code/byterun/pyvm2.py:334 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Define the global at module level before the function that reads it runs.","Check the spelling of the global name and that the module defining it was imported.","If the name should be a builtin, verify it exists in this Python version or provide it explicitly."],"exampleFix":"counter = 0\ndef bump():\n    global counter\n    counter += 1  # global defined at module scope before bump() is called","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fba689d101eb5600f5c8f4d7fd79912498e950e2","analyzedAt":"2026-08-13T06:26:32.792Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}