Repository: nvaccess/nvda

Issue:
Duplicate alert role in controlTypes
In controlTypes.py

* Line 120: ROLE_ALERT=114
* Line 144: ROLE_ALERT=138
* Line 430 and 431: # Translators: Identifies an alert message such as file download alert in Internet explorer 9 and above.
	ROLE_ALERT:_("alert"),
* Line 476 and 477: # Translators: Identifies an alert window or bar (usually on Internet Explorer 9 and above for alerts such as file downloads or pop-up blocker).
	ROLE_ALERT:_("alert"),

Thanks to @Dkager who actually noticed this


Discussion:
This might be compatibility stuff. I vaguely recollect Jamie telling me
this.

On Fri, Jun 2, 2017 at 2:50 PM, Leonard de Ruijter <notifications@github.com
> wrote:

> In controlTypes.py
>
>    - Line 120: ROLE_ALERT=114
>    - Line 144: ROLE_ALERT=138
>    - Line 430 and 431: # Translators: Identifies an alert message such as
>    file download alert in Internet explorer 9 and above.
>    ROLE_ALERT:_("alert"),
>    - Line 476 and 477: # Translators: Identifies an alert window or bar
>    (usually on Internet Explorer 9 and above for alerts such as file downloads
>    or pop-up blocker).
>    ROLE_ALERT:_("alert"),
>
> Thanks for @dkager <https://github.com/dkager> who actually noticed this
>
> —
> You are receiving this because you are subscribed to this thread.
> Reply to this email directly, view it on GitHub
> <https://github.com/nvaccess/nvda/issues/7247>, or mute the thread
> <https://github.com/notifications/unsubscribe-auth/AFGivSLUX53wXzt6AGFcR933QsCUQNFXks5sAHWxgaJpZM4NuxP4>
> .
>



-- 

Derek Riemer: Improving the world one byte at a time!

   - University of Colorado Boulder Department of computer science, 4th
   year undergraduate student.
   - Accessibility enthusiast.
   - Proud user of the NVDA screen reader.
   - Open source enthusiast.
   - Skier.

Personal website <http://derekriemer.com>

[**@derekriemer**](https://github.com/derekriemer) commented on [3 Jun 2017, 02:44 CEST](https://github.com/nvaccess/nvda/issues/7247#issuecomment-305938408 "2017-06-03T00:44:07Z - Replied by Github Reply Comments"):
> This might be compatibility stuff. I vaguely recollect Jamie telling me
> this.

I have a similar memory. @jcsteh, do you have an idea why we have two of these roles?
The compat argument doesn't hold actually because the scope is the same. Take this for example:

a = 1
b = 2
a = 2
print(a)

Of course a is 2 here.

Now,
thing[a] = "hi"
thing[b] = "bye"
thing[a] = hi

it's the same call.
If it's just a duplicate constant, removing the first instance is not a compat problem. What might be a problem is renumbering the constant values to fill the gap. While people should be using constants, not literal values, I'd probably advise against renumbering, not least because the diff would be silly. In short, remove the first instance, leave the second, but do not renumber.

The first assignment in the dict can also be removed, since the second one overrides it.
[**@jcsteh**](https://github.com/jcsteh) commented on [Jan 27, 2018, 9:57 PM MST](https://github.com/nvaccess/nvda/issues/7247#issuecomment-361038393 "2018-01-28T04:57:13Z - Replied by Github Reply Comments"):
> If it's just a duplicate constant, removing the first instance is not a compat problem. What might be a problem is renumbering the constant values to fill the gap. While people should be using constants, not literal values, I'd probably advise against renumbering, not least because the diff would be silly. In short, remove the first instance, leave the second, but do not renumber.

So remove the first constant val, but keep the number in the dict?


No, remove the constant and the dict entry, but don't renumber the rest of
the constants. There'll just be a numbering gap. Might be worth a code
comment if you're worried about confusion, but I'm not that concerned.

@derekriemer, @jcsteh I was looking through the code and was thinking to solve this issue because this seems even easy enough for me to do it and it is a good exercise to jump into understanding the source code.

But I have a concern here. What if some people used the constant 114 for alert role in their addons / app modules or in the controler client? Removing this entry from the dict would break functionality. Or am I wrong?
Or at least it could cause alert not to be reported.

Resolving patch:
diff --git a/source/controlTypes.py b/source/controlTypes.py
--- a/source/controlTypes.py
+++ b/source/controlTypes.py
@@ -119,7 +119,6 @@
 ROLE_TREEVIEWBUTTON=111
 ROLE_IPADDRESS=112
 ROLE_DESKTOPICON=113
-ROLE_ALERT=114
 ROLE_INTERNALFRAME=115
 ROLE_DESKTOPPANE=116
 ROLE_OPTIONPANE=117
@@ -435,8 +434,6 @@
 	ROLE_IPADDRESS:_("IP address"),
 	# Translators: Identifies a desktop icon (the icons on the desktop such as computer and various shortcuts for programs).
 	ROLE_DESKTOPICON:_("desktop icon"),
-	# Translators: Identifies an alert message such as file download alert in Internet explorer 9 and above.
-	ROLE_ALERT:_("alert"),
 	# Translators: Identifies an internal frame. This is usually a frame on a web page; i.e. a web page embedded within a web page.
 	ROLE_INTERNALFRAME:_("frame"),
 	# Translators: Identifies desktop pane (the desktop window).


Test patch: