Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"AttributeError: 'str' object has no attribute 'value'" in __iter__(self) #3

Open
wschmid4711234 opened this issue Apr 13, 2022 · 1 comment

Comments

@wschmid4711234
Copy link

PS C:\WINDOWS\system32> python
Python 3.9.12 (tags/v3.9.12:b28265d, Mar 23 2022, 23:52:46) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> import pyMSVC
>>> environment = pyMSVC.Environment()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Programme\Python39\lib\pyMSVC\__init__.py", line 361, in __init__
    self.visual_c = VisualCInfo(
  File "C:\Programme\Python39\lib\pyMSVC\__init__.py", line 683, in __init__
    distutils.log.debug(str(installation) + '\n\n')
  File "C:\Programme\Python39\lib\pyMSVC\vswhere.py", line 602, in __str__
    for line in str(self.properties).split('\n')
  File "C:\Programme\Python39\lib\pyMSVC\vswhere.py", line 976, in __str__
    return '\n'.join(str(prop) for prop in self)
  File "C:\Programme\Python39\lib\pyMSVC\vswhere.py", line 976, in <genexpr>
    return '\n'.join(str(prop) for prop in self)
  File "C:\Programme\Python39\lib\pyMSVC\vswhere.py", line 973, in __iter__
    yield Property(n.value, v)
AttributeError: 'str' object has no attribute 'value'

Fix:

    def __iter__(self):
        for n in self.names:
            v = VARIANT()
            # noinspection PyUnresolvedReferences
            self.GetValue(n, ctypes.byref(v))
            v = v.value
            if isinstance(v, BSTR):
                v = v.value

            if isinstance(n, str):                <-- added
                yield Property(n, v)            <-- added
            else:                                      <-- added
                yield Property(n.value, v)   <-- offending line

My system (output after fixing the code):

PS C:\WINDOWS\system32> python
Python 3.9.12 (tags/v3.9.12:b28265d, Mar 23 2022, 23:52:46) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> import pyMSVC
>>> environment = pyMSVC.Environment()
>>> print(environment)
Machine architecture: x64
Build architecture: x64

== Python =====================================================
  version: 3.9.12.final.0
  architecture: x64
  library: Python39.lib
  libs: ['C:\\Programme\\Python39\\libs']
  includes: ['C:\\Programme\\Python39\\include', 'C:\\Programme\\Python39\\include\\cpython', 'C:\\Programme\\Python39\\
include\\internal']

== Visual Studio Build Tools 2019==============================================
   description:        Die Visual Studio Build Tools ermöglichen Ihnen die Erstellung nativer und verwalteter MSBuild-ba
sierter Anwendungen, ohne dass die Visual Studio-IDE erforderlich ist. Es stehen Optionen zur Installation von Visual C+
+-Compilern und -Bibliotheken, MFC, ATL sowie C++/CLI-Unterstützung zur Verfügung.
   version:            16.11.32228.343
   version (friendly): 2019
   display version:    16.11.11
   path:               C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools
   executable:         C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\Common7\Tools\LaunchDevCmd.bat
   is complete:        True
   is prerelease:      False
   is launchable:      True
   state:              local, registered, no reboot required

== Visual C ===================================================
   version: 14.29.30141
   path:    C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC

   -- Tools ---------------------------------------------------
      version:     14.29.30133
      path:        C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133
      redist path: C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Redist\MSVC\14.29.30133\
   -- F# ------------------------------------------------------
      path: None
   -- DLL -----------------------------------------------------
      version: v142-14.29.30139.0
      path:    C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Redist\MSVC\14.29.30133\x64\Microsoft.V
C142.CRT

== MSBuild ====================================================
   version: 16.11.2.50704
   path:    C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin\MSBuild.exe

== HTML Help ==================================================
   path: None

== ATLMFC =====================================================
   path:         None
   include path: None
   lib path:     None

== Windows SDK ================================================
   version:     10.0
   sdk version: 10.0.19041.0
   path:        C:\Program Files (x86)\Windows Kits\10\

== Universal CRT ==============================================
   version:           10.0.19041.0
   path:              C:\Program Files (x86)\Windows Kits\10\
   lib directory:     C:\Program Files (x86)\Windows Kits\10\Lib\10.0.19041.0\ucrt\x64\
   headers directory: C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\ucrt\

== Extension SDK ==============================================
   path: C:\Program Files (x86)\Microsoft SDKs\Windows Kits\10\ExtensionSDKs

== TypeScript =================================================
   path: None

== .NET =======================================================
   version:    v4.6.81.2

   -- x86 -----------------------------------------------------
      version: v4.6.81.2
      path:    C:\WINDOWS\Microsoft.NET\Framework
   -- x64 -----------------------------------------------------
      version: v4.6.81.2
      path:    C:\WINDOWS\Microsoft.NET\Framework64
   -- NETFX ---------------------------------------------------
      path:         None
      x86 exe path: None
      x64 exe path: None
@kdschlosser
Copy link
Owner

I know about this and I have fixed it on my local copy. The version used in phoenix is also slightly different then this one. I will update this version in a few days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants