Skip to content

bin/fork_counter.py raises NameError on import: stray 'Y' before the copyright header #17

Description

@Avicennasis

Summary

bin/fork_counter.py begins with a stray Y immediately before the copyright comment:

Y# Copyright 2011 Splunk, Inc.

Python parses that Y as a bare expression statement referencing an undefined name, so the module raises NameError the moment it is imported. The file is still syntactically valid, which is why linters and ast.parse do not flag it.

Reproduction

Against the current master copy of the file:

$ python3 -c "import importlib.util; s=importlib.util.spec_from_file_location('fc','bin/fork_counter.py'); m=importlib.util.module_from_spec(s); s.loader.exec_module(m)"
NameError: name 'Y' is not defined

ast.parse() on the same file returns cleanly — the defect is at execution, not parse time.

Scope, stated honestly

Removing the stray Y is necessary but not sufficient on Python 3. With it removed, the same import instead fails with:

ModuleNotFoundError: No module named 'Queue'

Queue was renamed to queue in Python 3, so this module is Python 2 code. On a Python 2 runtime the Y is the only blocker; on Python 3 it is the first of two. I have not attempted a Python 3 port, only the one-character fix.

Fix

Deleting the single leading Y character resolves the NameError. That change is included in PR #16, which was opened for unrelated documentation typos in the same directory and happens to cover this line. Happy to split it into a standalone PR if you would prefer the fix reviewed separately from the typo changes.

Found via an automated typo scan; the surrounding grammar fixes in that PR are cosmetic, but this one is a genuine runtime defect and seemed worth reporting on its own.

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