Skip to content

[RFT Bug] An excluded name is kept at a nested def but renamed at its call sites #2380

Description

@AlecHaring

Excluding a name keeps the def, but references to it are still renamed, so the call raises NameError.

Input

main.py

from pkg.core import run

print(run())

pkg/__init__.py - empty package marker

pkg/core.py

def run():
    def worker():
        return 1

    return worker()

Steps

pyarmor init -s . -p pkg -e main.py
pyarmor env -p push rft:exclude_names 'worker'
pyarmor build --rft

Refactored output (the inconsistency)

dist/pkg/core.py

def pyarmor__1():

    def worker():
        return 1
    return pyarmor__2()

Running the refactored code:

Traceback (most recent call last):
  File "main.py", line 2, in <module>
    print(pyarmor__1())
          ^^^^^^^^^^^^
  File "pkg/core.py", line 5, in pyarmor__1
    return pyarmor__2()
           ^^^^^^^^^^
NameError: name 'pyarmor__2' is not defined. Did you mean: 'pyarmor__1'?

Environment

  • PyArmor: 9.2.7 (pro), build 005037
  • Python: 3.11.9
  • Platform: windows.x86_64 (Windows 11)
  • Mode: RFT (pyarmor build --rft)

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