View Issue Details

IDProjectCategoryView StatusLast Update
0016265ScribusScripterpublic2020-11-07 14:52
Reportersreerajp Assigned Tojghali  
PriorityhighSeveritymajorReproducibilityalways
Status closedResolutionfixed 
PlatformWindowsOS10OS Version1909
Product Version1.5.6.svn 
Fixed in Version1.5.6.svn 
Summary0016265: Python script error when using "i" as a variable name
DescriptionPython - 3.8.1

My Script is
import scribus
i = scribus.ImageExport()
i.type = "jpg"
print(i.type)

Error Displayed
1024
Traceback (most recent call last):
  File "<console>", line 1, in <module>
AttributeError: 'str' object has no attribute 'type'
Traceback (most recent call last):
  File "<console>", line 1, in <module>
AttributeError: 'str' object has no attribute 'type'
TagsNo tags attached.
PatchNo

Activities

jghali

2020-10-09 12:52

administrator   ~0048152

Unable to reproduce here.

sreerajp

2020-10-09 13:04

reporter   ~0048154

When I changed the script as below it is working

import scribus
im = scribus.ImageExport()
im.type = "JPG"
im.dpi = 150
print(im.dpi)

jghali

2020-10-09 17:24

administrator   ~0048156

After investigation, it appears this is a python 3.8 behavior change or issue when assigning a variable to another variable already defined with another type. In this case, "i" was already used as an internal variable with type string. With python 3.7, the line "i = scribus.ImageExport()" appropriately change the type of "i", with python 3.8 the type change apparently does not occur and after assignment, python 3.8 still considers "i" as a string.

I committed an easy workaround which avoid using this common variable name.

Issue History

Date Modified Username Field Change
2020-10-09 07:10 sreerajp New Issue
2020-10-09 12:52 jghali Note Added: 0048152
2020-10-09 13:04 sreerajp Note Added: 0048154
2020-10-09 17:24 jghali Assigned To => jghali
2020-10-09 17:24 jghali Status new => resolved
2020-10-09 17:24 jghali Resolution open => fixed
2020-10-09 17:24 jghali Fixed in Version => 1.5.6.svn
2020-10-09 17:24 jghali Note Added: 0048156
2020-10-09 17:24 jghali Summary While running ImageExport() python script error is coming => Python script error when using "i" as a variable name
2020-11-07 14:52 cbradney Status resolved => closed