Skip to content

Commit cf12b88

Browse files
author
Matthew Fisher
committed
fix(create_bucket): check for existence of None
There are small implications between `if not x` and `if x is None` in Python: - `if not x` checks if the value is false (empty list, `None`, `False`) - `if x is None` checks if x is equal to the literal value `None`. conn.lookup returns `None` if no bucket exists. This code is explicitly stated in their docs as the proper way to check if a bucket does not exist. See: http://boto.readthedocs.org/en/latest/s3_tut.html
1 parent d4673ea commit cf12b88

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

database/templates/create_bucket

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ conn = boto.connect_s3(
1212
calling_format=OrdinaryCallingFormat())
1313
name = sys.argv[1]
1414

15-
if not conn.lookup(name):
15+
if conn.lookup(name) is None:
1616
conn.create_bucket(name)

registry/templates/create_bucket

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@ name = '{{ getv "/deis/registry/s3bucket" }}'
2222
name = '{{ getv "/deis/registry/bucketName" }}'
2323
{{ end }}
2424

25-
if not conn.lookup(name):
25+
if conn.lookup(name) is None:
2626
conn.create_bucket(name)

0 commit comments

Comments
 (0)