Opened 16 years ago
Closed 16 years ago
#64 closed defect (fixed)
bug in Tub.registerReference when name provided
Reported by: | bgranger | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | 0.2.8 |
Component: | unknown | Version: | 0.2.5 |
Keywords: | Tub | Cc: |
Description (last modified by )
The following call doesn't work:
mytub.registerReference(fooo, 'fooname', furlFile='foo.furl')
If foo.furl already exists. This is because in registerReference, there is code:
oldfurl = None if furlFile: try: oldfurl = open(furlFile, "r").read().strip() except EnvironmentError: pass if oldfurl: if name is None: sr = SturdyRef(oldfurl) name = sr.name if self.tubID != sr.tubID: # problem occurs here!!! raise WrongTubIdError("I cannot keep using the old FURL (%s)" " because it does not have the same" " TubID as I do (%s)" % (oldfurl, self.tubID))
If there is an existing furlFile (oldfurl == True), but there is a name set, no local object called sr gets created and an exception is raised.
The following seems to fix the problem:
oldfurl = None if furlFile: try: oldfurl = open(furlFile, "r").read().strip() except EnvironmentError: pass if oldfurl: sr = SturdyRef(oldfurl) if name is None: name = sr.name if self.tubID != sr.tubID: raise WrongTubIdError("I cannot keep using the old FURL (%s)" " because it does not have the same" " TubID as I do (%s)" % (oldfurl, self.tubID))
By moving the creation of sr outside the if name is None test, the sr object gets created no matter what so it is available in the subsequent if self.tubID != sr.tubID test.
Change History (3)
comment:1 Changed 16 years ago by
Description: | modified (diff) |
---|
comment:2 Changed 16 years ago by
Milestone: | undecided → 0.2.8 |
---|
comment:3 Changed 16 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
Note: See
TracTickets for help on using
tickets.
fix code formatting