GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • CodeQL documentation
  • CodeQL overview
  • Writing CodeQL queries
  • CodeQL language guides
  • QL language reference
  • CodeQL standard-libraries
  • CodeQL query help
  • CodeQL repository
  • QL publications
  • CodeQL query help for C and C++
  • CodeQL query help for C#
  • CodeQL query help for GitHub Actions
  • CodeQL query help for Go
  • CodeQL query help for Java and Kotlin

This view

  • Original page
  • New address

GeezerVison is showing codeql.github.com — Deprecated slice method — CodeQL query help documentation

Deprecated slice method¶

ID: py/deprecated-slice-method
Kind: problem
Security severity: 
Severity: warning
Precision: very-high
Tags:
   - maintainability
Query suites:
   - python-security-and-quality.qls

Click to see the query in the CodeQL repository

The __getslice__, __setslice__ and __delslice__ methods have been deprecated since Python 2.0. In general, no class should implement these methods.

The only exceptions to this rule are classes that inherit from list and override __getitem__, __setitem__ or __delitem__. Since list implements the slicing methods any class inheriting from list must implement the the slicing methods to ensure correct behavior of __getitem__, __setitem__ and __delitem__. These exceptions to the rule will not be treated as violations.

Recommendation¶

Delete the slicing method. Any functionality should be moved to the equivalent __xxxitem__ method:

  • __getslice__ should be replaced with __getitem__

  • __setslice__ should be replaced with __setitem__

  • __delslice__ should be replaced with __delitem__

References¶

  • Python Language Reference: Additional methods for emulation of sequence types.

  • © GitHub, Inc.
  • Terms
  • Privacy
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.