You sure it does raise an error in yours with that simple/trivial example?

Yes. Notice that it prints idx = 3. The evaluation of self.bob[3] raises an IndexError. The Python interpreter catches this error and stops the for loop.
This doesn’t happen if you wrap it in a DataLoader like in @Prerna_Dhareshwar’s example because DataLoader uses __len__.
Here is the full runnable example:
from torch.utils.data import Dataset

class MyDataset(Dataset):
    def __init__(self):
        self.bob = [0,1,2]

    def __len__(self):
        print('len')
        return 0

    def __getitem__(self, idx):
        print(f'idx = {idx}')
        return self.bob[idx]


dataset = MyDataset()
for i, data in enumerate(dataset):
    print(i)
    print(data)

Here is the output:
idx = 0
0
0
idx = 1
1
1
idx = 2
2
2
idx = 3