question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

build_file_import_whitelist = os.path doesn't work

See original GitHub issue
[project]
  build_file_import_whitelist = os.path

doesn’t work—I get the error

AttributeError: Using function expanduser is forbidden in the safe version of module os.path. If you really need to use this function read about allow_unsafe_import() documented at: https://buckbuild.com/function/allow_unsafe_import.html

Is this because the module name has multiple parts? Is it because Buck already imports the “safe” version of os.path? How can I whitelist os.path methods without using allow_unsafe_import() everywhere?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
jiangty-addeparcommented, Oct 20, 2017

Oh, that’s even simpler than what I was thinking! Nice 😃

0reactions
ttsugriycommented, Oct 20, 2017

using os.path.exists() to check for test resources directory is a bad idea, because buck is not aware of this and would have no way to know what exactly should be invalidated and in you can easily end up in a situation with non-reproducible and hard to understand failure. If nothing else you can probably at least use something like:

test_resources = glob(['your_pattern'])
if test_resources:
  # handle test resources
else:
  # there are no test resources
Read more comments on GitHub >

github_iconTop Results From Across the Web

os.walk without digging into directories below - Stack Overflow
Don't use os.walk. Example: import os root = "C:\\" for item in os.listdir(root): if os.path.isfile(os.path.join(root, item)): print item.
Read more >
allow_unsafe_import() - Buck
Some modules can be imported in a normal way (without using allow_unsafe_import() ) because they were whitelisted or a safe version was configured....
Read more >
How to Check If a File Exists in Python
To check if a file exists, you pass the file path to the exists() function from the os.path standard library. First, import the...
Read more >
build/check_gn_headers.py - chromium/src - Git at Google
"""Find header files missing in GN. This script gets all the header files from ninja_deps, which is from the true. dependency generated ...
Read more >
os.path — Common pathname manipulations — Python 3.11 ...
This module implements some useful functions on pathnames. To read or write files see open() , and for accessing the filesystem see the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found