Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

__file__ is not defined #510

Closed
mtshiba opened this issue May 1, 2024 · 0 comments
Closed

__file__ is not defined #510

mtshiba opened this issue May 1, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@mtshiba
Copy link
Member

mtshiba commented May 1, 2024

From: #508

print! __file__
$ erg test.er    
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "test.er", line -1, in <module>
NameError: name '__file__' is not defined. Did you mean: '__name__'?

Erg does not create files (on Unix) when executing Python bytecode. That is, __file__ is not set. Even if the compiler creates the file, it will be created in the temporary directory, so it won't work as intended anyway.
The compiler must embed the contents of this variable at compile time.


Originally posted by @toddlerer in #508 (comment)

@mtshiba mtshiba added the bug Something isn't working label May 1, 2024
@mtshiba mtshiba closed this as completed in 50787a0 May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant