Reject package (extension) names that can't be valid Python identifiers #3679

Merged
Jackenmen merged 3 commits from V3/issue_3605 into V3/develop 2020-08-03 15:17:28 +02:00
Jackenmen commented 2020-03-21 14:20:39 +01:00 (Migrated from github.com)

Type

  • Bugfix
  • Enhancement
  • New feature

Description of the changes

Resolves #3605

### Type - [x] Bugfix - [x] Enhancement - [ ] New feature ### Description of the changes Resolves #3605
tekulvw (Migrated from github.com) reviewed 2020-03-21 14:20:39 +01:00
Jackenmen commented 2020-04-12 15:20:16 +02:00 (Migrated from github.com)

This PR can now be reviewed, it's only labeled as Blocked to prevent an accidental merges before we're actually ready for 3.4 release.

This PR can now be reviewed, it's only labeled as Blocked to prevent an accidental merges before we're actually ready for 3.4 release.
mikeshardmind commented 2020-07-06 21:15:03 +02:00 (Migrated from github.com)

Seems fine, but I'd reword this to us the appropriate d.py term (extensions, not cogs)

Seems fine, but I'd reword this to us the appropriate d.py term (extensions, not cogs)
Drapersniper (Migrated from github.com) requested changes 2020-07-14 12:05:20 +02:00
Drapersniper (Migrated from github.com) left a comment

Everything is looking good however
If you had an invalid cog loaded before this change you will see the following, Can you please handle this error and log a log.error message saying that we are unable to load the cog as it is not a valid package name (No traceback please as this traceback is super misleading for this case).

[2020-07-14 11:02:22] [ERROR] red: Failed to load package zippe$r
Traceback (most recent call last):
  File "C:\Users\guyre\.virtualenvs\red\lib\site-packages\redbot\core\bot.py", line 660, in pre_flight
    await asyncio.wait_for(self.load_extension(spec), 30)
  File "C:\Program Files\Python38\lib\asyncio\tasks.py", line 483, in wait_for
    return fut.result()
  File "C:\Users\guyre\.virtualenvs\red\lib\site-packages\redbot\core\bot.py", line 925, in load_extension
    name = spec.name.split(".")[-1]
AttributeError: 'NoneType' object has no attribute 'name'
Everything is looking good however If you had an invalid cog loaded before this change you will see the following, Can you please handle this error and log a `log.error` message saying that we are unable to load the cog as it is not a valid package name (No traceback please as this traceback is super misleading for this case). ``` [2020-07-14 11:02:22] [ERROR] red: Failed to load package zippe$r Traceback (most recent call last): File "C:\Users\guyre\.virtualenvs\red\lib\site-packages\redbot\core\bot.py", line 660, in pre_flight await asyncio.wait_for(self.load_extension(spec), 30) File "C:\Program Files\Python38\lib\asyncio\tasks.py", line 483, in wait_for return fut.result() File "C:\Users\guyre\.virtualenvs\red\lib\site-packages\redbot\core\bot.py", line 925, in load_extension name = spec.name.split(".")[-1] AttributeError: 'NoneType' object has no attribute 'name' ```
Drapersniper (Migrated from github.com) approved these changes 2020-07-20 11:55:47 +02:00
Drapersniper (Migrated from github.com) left a comment

LGTM: #4079 was merged which will now provide a more friendly error ...
However i think we should do another error specific to this PR where the identifier is invalid.

But won't be not approving this PR due to that nitpick.

LGTM: #4079 was merged which will now provide a more friendly error ... However i think we should do another error specific to this PR where the identifier is invalid. But won't be not approving this PR due to that nitpick.
Sign in to join this conversation.
No labels
Automated PR
Blocked
Blocked By: Damage Control
Blocked By: Dependency
Blocked By: Other PR
Breaking Change
Category: CI
Category: Cogs - Admin
Category: Cogs - Alias
Category: Cogs - Audio
Category: Cogs - Bank
Category: Cogs - Cleanup
Category: Cogs - CustomCommands
Category: Cogs - Dev
Category: Cogs - Downloader
Category: Cogs - Economy
Category: Cogs - Filter
Category: Cogs - General
Category: Cogs - Image
Category: Cogs - Mod
Category: Cogs - Modlog
Category: Cogs - Mutes
Category: Cogs - Permissions
Category: Cogs - Reports
Category: Cogs - Streams
Category: Cogs - Trivia
Category: Cogs - Trivia - Lists
Category: Cogs - Warnings
Category: Core - API - App Commands Package
Category: Core - API - Audio
Category: Core - API - Bank
Category: Core - API - Commands Package
Category: Core - API - Config
Category: Core - API - Other
Category: Core - API - Utils Package
Category: Core - Bot Class
Category: Core - Bot Commands
Category: Core - Command-line Interfaces
Category: Core - Downloader
Category: Core - Help
Category: Core - i18n
Category: Core - Modlog
Category: Core - Other Internals
Category: Core - RPC/ZMQ
Category: Docker
Category: Docs - Changelogs
Category: Docs - For Developers
Category: Docs - Install Guides
Category: Docs - Other
Category: Docs - User Guides
Category: Meta
Category: RPC/ZMQ methods
Category: Vendored Packages
Changelog Entry: Added
Changelog Entry: Pending
Changelog Entry: Skipped
Closed: Duplicate
Closed: External
Closed: Invalid
Closed: User Error
Closed: Won't Fix
Complex Issue
Docs-only
Feature Branch
Good First Issue
Help Wanted
High Priority
Needs Backport To stable-docs
No Activity
No Repro
QA: Bypassed
QA: Changes Requested
QA: Passed
Release Blocker
Status: Accepted
Status: Frozen
Status: In Progress
Status: Needs Discussion
Status: Needs Info
Status: Needs Triage
Status: PRs Welcome
Type: Bug
Type: Dependency Update
Type: Deprecation
Type: Enhancement
Type: Feature
Type: Informational
Type: Merge
Type: Optimisation
Type: Question
Type: Removal
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Mrcoolgamer11/Red-DiscordBot!3679
No description provided.