Skip to content

Commit

Permalink
Fix bug: use sys instead of inspect to obtain stack
Browse files Browse the repository at this point in the history
`sys` has less dependencies than `inspect` and is trouble-less
  • Loading branch information
hsfzxjy committed Feb 7, 2021
1 parent f2a6085 commit 8a43346
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions lambdex/__init__.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import os
import sys
import inspect

for f in inspect.stack()[1:]:
if not f.filename.startswith('<'):
break
f = sys._getframe(1)
while f.f_code is not None and f.f_code.co_filename.startswith('<'):
f = f.f_back

if f.filename.startswith(os.path.dirname(os.__file__)):
if f and f.f_code and f.f_code.co_filename.startswith(os.path.dirname(os.__file__)):
if sys.path and sys.path[0] == os.getcwd():
sys.path = sys.path[1:]
else:
__all__ = ['def_']
from .keywords import def_

del os, sys, inspect, f
del os, sys, f

__version__ = "0.1.0"

0 comments on commit 8a43346

Please sign in to comment.