python - garbage collection and reference counting -


It's easily weird bug that went in some time. I want to give you a snippet of code that I am working on. This code reaches some Django apis but is not particularly important on those features (I hope). Def handle_location (self): zip_code_location = Location.objects.filter (zip_code = self.cleaned_data.get ('ZIP_CODE')) Otherwise zip_code_location: forms.ValidationError lift ('invalid zip code Returned. ', Code =' invalid_zip_code ') and: zip_code_location = zip_code_location [0] city, state = map (lambda x: .. x.strip () less (), self.cleaned_data.get (' location_raw ') partition (',')) Try: map_citystate_to_location (city, state) as city_state_location = e except LocationMatchingException: logging.error (d. Message + 'location_raw: {} and ZIP_CODE: {}' format (self.cleaned_data .get ('location'), self.cleaned_data ('ZIP_CODE'), exc_info = true, stack_info = true)) forms.ValidationErro increased R ( 'Something is wrong in that place!', Code = 'Invalid_space') # Compare these by zip code. If we do not overload a __eq__ operator, then city_state_location.zip_code = zip_code_location.zip_code: logging.error ('zipcode client raw Returned from the city and mapped to a different place than the 'returned' state customer \ N. '' Location_raw: {} \ n "'match with location ZIP_CODE: {} \ n" Location matches with city and state: {}'. Format (self.cleaned_data.get ('location'), zip_code_location, city_state_location, exc_info = true, stack_info = true)) forms.ValidationError ('something wrong with such a place!', Code = 'INVALID_LOCATION') .cleaned_data ['location'] = zip_code_location

We create a variable named Zip_code_locatio at the very beginning and assign it a location object. Location object is a fairly simple class that starts Django.db.models.model. As far as Django goes, it does not do anything in general. By any means, we store our zip_code_location in a clean dictionary and walk like ours.

Function handle_pace is called by a clean function called Normally if I check the value of clean-a-dita clearly, then it looks like:

 < 'Date_time': datetime.time (1, 57), 'location_raw': 'Manhattan BC, CA', 'Start_date': 'datetime.date (2014, 10, 28),' Payment_mity ':' G ' , 'Zipcode': '90266', 'value': 2324.0, 'title': 'aids', 'location': & lt; Location: Manhattan Beach, CA 90266 - Latitude: 33.88 Long: -118.40 - Population 30505, 'start_datetime': datetime.datetime (2014, 10, 28, 8, 57, tzinfo = & lt; UTC & gt;) 'Type': 'T'}  

Note that the location is there. I got a special place where this is not the case. The key / value pair is present in itself. Scanned as the data leave handle_location to the program but then it completely disappears because we press the return statement and move the stack up. what the heck???? It is almost like the garbage collector that there was no other reference pointing to zip_code_location for the original example and decided to clean it. But obviously this should not be the case. Anyone know what is happening? And why can it apply to some inputs?

Thanks for any insights

Nick

EDIT: I was wrong. When we go up the stack, the key / value pair does not disappear, it is never assigned to itself in the first place. When I step through the code in the debugger and check the value of the cleaned_data on the line reading "return", it does not contain a "location" key. Can there be a property that can be used to deny my input? Can it cause?


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -