@@ -332,19 +332,19 @@ def InitTempVars(self, name):
332332 # timestamp is newer than the modtime of the config.pck file, we don't
333333 # need to reload, otherwise... we do.
334334 self .__timestamp = 0
335- self .__lock = LockFile .LockFile (
336- os .path .join (mm_cfg .LOCK_DIR , name or '<site>' ) + '.lock' ,
337- # TBD: is this a good choice of lifetime?
338- lifetime = mm_cfg .LIST_LOCK_LIFETIME ,
339- withlogging = mm_cfg .LIST_LOCK_DEBUGGING )
340- # Ensure name is a string
335+ # Ensure name is a string before using it in os.path.join
341336 if isinstance (name , bytes ):
342337 try :
343338 # Try Latin-1 first since that's what we're seeing in the data
344339 name = name .decode ('latin-1' , 'replace' )
345340 except UnicodeDecodeError :
346341 # Fall back to UTF-8 if Latin-1 fails
347342 name = name .decode ('utf-8' , 'replace' )
343+ self .__lock = LockFile .LockFile (
344+ os .path .join (mm_cfg .LOCK_DIR , name or '<site>' ) + '.lock' ,
345+ # TBD: is this a good choice of lifetime?
346+ lifetime = mm_cfg .LIST_LOCK_LIFETIME ,
347+ withlogging = mm_cfg .LIST_LOCK_DEBUGGING )
348348 self ._internal_name = name
349349 if name :
350350 self ._full_path = Site .get_listpath (name )
@@ -366,6 +366,14 @@ def InitVars(self, name=None, admin='', crypted_password='',
366366 """Assign default values - some will be overriden by stored state."""
367367 # Non-configurable list info
368368 if name :
369+ # Ensure name is a string
370+ if isinstance (name , bytes ):
371+ try :
372+ # Try Latin-1 first since that's what we're seeing in the data
373+ name = name .decode ('latin-1' , 'replace' )
374+ except UnicodeDecodeError :
375+ # Fall back to UTF-8 if Latin-1 fails
376+ name = name .decode ('utf-8' , 'replace' )
369377 self ._internal_name = name
370378
371379 # When was the list created?
@@ -593,6 +601,14 @@ def GetConfigInfo(self, category, subcat=None):
593601 #
594602 def Create (self , name , admin , crypted_password ,
595603 langs = None , emailhost = None , urlhost = None ):
604+ # Ensure name is a string
605+ if isinstance (name , bytes ):
606+ try :
607+ # Try Latin-1 first since that's what we're seeing in the data
608+ name = name .decode ('latin-1' , 'replace' )
609+ except UnicodeDecodeError :
610+ # Fall back to UTF-8 if Latin-1 fails
611+ name = name .decode ('utf-8' , 'replace' )
596612 if name != name .lower ():
597613 raise ValueError ('List name must be all lower case.' )
598614 if Utils .list_exists (name ):
0 commit comments