Skip to content

Commit bb1567d

Browse files
committed
Explained why os.getcwd is used for path finding
1 parent 08bf538 commit bb1567d

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

flask/helpers.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,8 @@ def get_root_path(import_name):
484484
directory = os.path.dirname(sys.modules[import_name].__file__)
485485
return os.path.abspath(directory)
486486
except AttributeError:
487+
# this is necessary in case we are running from the interactive
488+
# python shell. It will never be used for production code however
487489
return os.getcwd()
488490

489491

@@ -499,6 +501,7 @@ def find_package(import_name):
499501
root_mod = sys.modules[import_name.split('.')[0]]
500502
package_path = getattr(root_mod, '__file__', None)
501503
if package_path is None:
504+
# support for the interactive python shell
502505
package_path = os.getcwd()
503506
else:
504507
package_path = os.path.abspath(os.path.dirname(package_path))

0 commit comments

Comments
 (0)