title: Python throws KeyError: 1 when using a Dictionary restored from a file
body: <p>In my program, I have certain settings that can be modified by the user, saved on the disk, and then loaded when application is restarted. Some these settings are stored as dictionaries. While trying to implement this, I noticed that after a dictionary is restored, it's values cannot be used to access values of another dictionary, because it throws a KeyError: 1 exception.</p>
  <p>This is a minimal code example that ilustrates the issue:</p>
  <pre><code>import json
  
  motorRemap = {
      1: 3,
      2: 1,
      3: 6,
      4: 4,
      5: 5,
      6: 2,
  }
  
  motorPins = {
      1: 6,
      2: 9,
      3: 10,
      4: 11,
      5: 13,
      6: 22
  }
  
  print(motorPins[motorRemap[1]]); #works correctly
  
  with open('motorRemap.json', 'w') as fp:
      json.dump(motorRemap, fp)
  
  with open('motorRemap.json', 'r') as fp:
      motorRemap = json.load(fp)
  
  print(motorPins[motorRemap[1]]); #throws KeyError: 1
  </code></pre>
  <p>You can run this code as it is. First print statement works fine, but after the first dictionary is saved and restored, it doesn't work anymore. Apparently, saving/restoring somehow breaks that dictionary.</p>
  <p>I have tried saving and restoring with json and pickle libraries, and both produce in the same error. I tried printing values of the first dictionary after it is restored directly ( <code>print(motorRemap[1]</code>), and it prints out correct values without any added spaces or anything. KeyError usually means that the specified key doesn't exist in the dictionary, but in this instance print statement shows that it does exist - unless some underlying data types have changed or something. So I am really puzzled as to why this is happening.</p>
  <p>Can anyone help me understand what is causing this issue, and how to solve it?</p>